如何使用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;
未能解决您的问题?

请提交 联系工单