dongyun8138 2019-01-25 10:12
浏览 204

Wordpress - 显示指向当前页面路径的页面

I'm working with Wordpress. My goal is to display dynamical path to the current page - something like this: Home / Blog / Post - Name. It's inside blog page so it can't be done using static html since it's dynamically changing (or maybe with help of ACF?).

All i found was next/previous links and tutorials how to use it. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doujiyuan0211 2019-01-25 14:02
    关注

    We’ve created a custom function called get_breadcrumb() to generate the breadcrumb links. You only need to add the get_breadcrumb() function code in functions.php file of the current theme.

    function get_breadcrumb() {
        echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
        if (is_category() || is_single()) {
            echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
            the_category(' &bull; ');
                if (is_single()) {
                    echo " &nbsp;&nbsp;&#187;&nbsp;&nbsp; ";
                    the_title();
                }
        } elseif (is_page()) {
            echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
            echo the_title();
        } elseif (is_search()) {
            echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;Search Results for... ";
            echo '"<em>';
            echo the_search_query();
            echo '</em>"';
        }
    }
    

    Display Breadcrumbs: Call the get_breadcrumb() function in single.php file and others files where you want to display the breadcrumbs on your WordPress site.

    <div class="breadcrumb"><?php get_breadcrumb(); ?></div>
    

    https://www.codexworld.com/wordpress-how-to-display-breadcrumb-without-plugin/

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)