Badcrumb如何显示带有父标题的页面标题>带有永久链接的子标题?有什么想法吗?

时间:2013-11-13 作者:Adeel
function the_breadcrumb() {
global $post;
if (!is_home()) {
    echo "";
        if(is_single()):
        echo \'Main\';
        else:
        echo "Home";
        endif;
    echo " / ";
        if ( is_category() || is_single() ) {
            the_category(\', \');
            if ( is_single() ) {
                echo " / ";
                the_title();
            }
        } elseif ( is_page() && $post->post_parent ) {
            echo "post_parent)."\\">".get_the_title($post->post_parent) . "";
            echo " / ";
            echo the_title();
        } elseif (is_page()) {
            echo \'\';
            echo the_title();
            echo "";
        }
    }
}

1 个回复
最合适的回答,由SO网友:Krzysiek Dróżdż 整理而成

您应该更改此行:

echo "post_parent)."\\">".get_the_title($post->post_parent) . "";
对这样的事情:

echo \'<a href="\'. get_permalink($post->post_parent).\'">\'. apply_filters(\'the_title\', get_the_title($post->post_parent)) .\'</a>\';

结束

相关推荐

_title();在循环外部的页面模板中工作。为什么?

试图让我的头脑围绕着循环的概念。。。给定一个模板页面(page work.php),其中只包含以下代码:<?php the_title(); ?> WP正确显示该页面的标题。据我所知,这超出了任何循环,不应该起作用(Codex说使用get_the_title 在这些情况下)。所以问题是,为什么它会起作用?有趣的是,这不会输出标题+内容,只会输出标题:<?php the_title(); the_content(); ?> 谢谢!