如何使用get_post和get_page獲取單個文章或頁面的詳細資訊?

使用 get_postget_page 獲取單個文章或頁面的詳細資訊:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 獲取文章或頁面的ID
$post_id = get_the_ID();
// 獲取文章或頁面的詳細資訊
$post = get_post($post_id);
// 獲取文章或頁面的標題
$title = $post->post_title;
// 獲取文章或頁面的內容
$content = $post->post_content;
// 獲取文章或頁面的ID $post_id = get_the_ID(); // 獲取文章或頁面的詳細資訊 $post = get_post($post_id); // 獲取文章或頁面的標題 $title = $post->post_title; // 獲取文章或頁面的內容 $content = $post->post_content;
// 獲取文章或頁面的ID  
$post_id = get_the_ID();  
  
// 獲取文章或頁面的詳細資訊  
$post = get_post($post_id);  
  
// 獲取文章或頁面的標題  
$title = $post->post_title;  
  
// 獲取文章或頁面的內容  
$content = $post->post_content;
未能解決您的問題?

請提交 聯絡工單