在WordPress中,如何获取父帖子的 URL(对于一种Up按钮)?
这是我用来提取父名称的代码:
<?php
if( empty($wp_query->post->post_parent) ) {
$parent_post_id = $wp_query->post->ID;
} else {
$parent_post_id = $wp_query->post->post_parent;
}
$parent_post = get_post($parent_post_id);
$parent_post_title = $parent_post->post_title;
echo $parent_post_title;