我有一个存储在变量中的页面ID号。但是,我正在尝试访问特定的页面ID号父页面标题。
谁能给我指路
请尝试使用以下代码:
get_the_title(wp_get_post_parent_id($your_post_ID));
当前页面:
<?php
echo empty( $post->post_parent ) ? get_the_title( $post->ID ) : get_the_title( $post->post_parent );
?>
如果这个ID是其他页面的ID,我会说在数据库上运行一个查询来获得那个标题。