我已经能够在Stackoverflow上使用其他开发人员(ref:Echo the subtitle of a PARENT page within WordPress - Part (2))来模拟基于从表中收集的数据的类似函数,但是,这将是填充的静态信息 .

What I need to be done:

如果您在主页上或使用页面的"Default"模板,则 Headers 将为"Homepage",URL将为“http://example.com ". In this scenario the page id will be " 0 " for the homepage and any children will share this relationship based off of " 0” .

如果您使用的是子品牌主页或使用此模板的页面,则 Headers 将为"Sub-brand",URL将为“http://example.com/sub ". In this scenario the homepage id will be " 67 " and any children will share this relationship based off of " 67” .

Current version of the function:

<?php 
    if ($post->post_parent!=67) {
        // Sub-brand - children
        echo = "Sub brand child";
        $title .= "Sub-brand";
        $link .= "\nhttp://example.com/sub";
    } elseif($post->ID==0||count(get_pages('child_of='.$post->ID))!=67) {
        // Sub-brand - home
        echo = "Sub brand home";
        $title .= "Sub-brand";
        $link .= "\nhttp://example.com/sub";
    } else {
        // Homepage and children
        echo = "Everything else";
        $title .= "Homepage";
        $link .= "\nhttp://example.com/";
    }
?>

Current issue(s):

  • 主页在初始"if"声明下分类,而不是"else"

  • 使用"Homepage"作为父级的子页面与"elseif"语句关联而不是"else"

What's working:

  • 子品牌主页正在由最初的"if"声明正确填充

  • 使用"Sub-brand"作为父级的子页面与"elseif"语句关联

任何帮助将得到赞赏,使协会正确 . 请注意,我已经使用PHP不到一个星期了,我正在学习 .