2023-06-11 / 737阅
<?php
$title = get_the_title();
echo $title;
?>
<?php
$content = get_the_content();
echo $content;
?>
<?php
$excerpt = get_the_excerpt();
echo $excerpt;
?>
<?php
$publish_date = get_the_date();
echo $publish_date;
?>
<?php
$author_name = get_the_author();
echo $author_name;
?>
<?php
$thumbnail_src = get_the_post_thumbnail_url();
echo $thumbnail_src;
?>
<?php
$categories = get_the_category();
foreach($categories as $category){
echo $category->name;
}
?>
<?php
$tags = get_the_tags();
foreach($tags as $tag){
echo $tag->name;
}
?>
注意:上述函数都是在循环中使用获取特定文章的信息。如果要获取当前文章的信息,则需要使用global $post
声明全局变量。例如:
<?php
global $post;
$title = get_the_title($post->ID);
echo $title;
?>
阅读文章或者观看视频过程中有任何问题,请下方留言或者联系我Q248758228