Original topic: Echo the subtitle of a PARENT page within WordPress?
我发现了对上面原始主题产生的代码Mark的单独需求 . 幸运的是,我能够与另一个社区成员合作,以实现类似的功能来处理该问题所涉及的相同元素的href .
我需要根据父页面的字幕值填充 Headers 标签 . 但是,如果没有设置父级,我需要它默认为整个站点的默认子 Headers .
我们在这里为href属性实现了这个目的:How to set a link based off a post_parent being set - WordPress
The current code is handled this way:
<?php
if ($post->post_parent) {
$permatitle = get_post_meta($post->post_parent, '_base_page_subtitle', true);
} else {
$permatitle = get_post_meta($post->ID, '_base_page_subtitle', true);
}
?>
<a href="<?php echo $permalink; ?>" title="<?php echo $permatitle; ?>">
但是,我还需要它来处理子页面 . 任何帮助将不胜感激,我会赞成任何有助于解决这个问题的人 .
1 回答
如果你想要达到同样的目的(refer here),但这次是为了冠军,
you can do this:
or better yet, combine the two:
then you can do this after: