markdown 如何在带有Timber / twig的WordPress网站上启用和使用Yoast Breadcrumbs

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 如何在带有Timber / twig的WordPress网站上启用和使用Yoast Breadcrumbs相关的知识,希望对你有一定的参考价值。

1.   Download and install the [Yoast SEO plugin](https://yoast.com/wordpress/plugins/seo/)
2.   Add the Yoast Breadcrumb function to timber context

      For Bloom Box, the timber context gets declared in timber.php, inside the `add_to_context` function
      ```php
      // Add Yoast Breadcrumbs to the context
        if ( function_exists( 'yoast_breadcrumb' ) ) {
            $context['breadcrumbs'] = yoast_breadcrumb('<nav id="breadcrumbs" class="main-breadcrumbs">','</nav>', false );
        }
      ```
3.   Add the code to call the breadcrumb function to a template

      For Bloom Box, I added it to system/base.twig, inside a block so we can disable it on any templates we don't want to have breadcrumbs
      ```php
      {% block breadcrumbs %}
				{% if breadcrumbs %}
					{{ breadcrumbs }}
				{% endif %}	
			{% endblock %}
      ```
4.   In the admin sidebar, under SEO/Search Appearance, enable Breadcrumbs

以上是关于markdown 如何在带有Timber / twig的WordPress网站上启用和使用Yoast Breadcrumbs的主要内容,如果未能解决你的问题,请参考以下文章

markdown 设置WP / ACF / Timber Twitter分享链接

markdown 集成Pattern Lab和WordPress(Timber / Twig)

markdown 将Gravity Forms作为变量传递给Twig / Timber

markdown 将Gravity Forms作为变量传递给Twig / Timber

鸿蒙开源第三方组件——日志工具组件Timber_ohos

Timber(Twig)如何调用wordpress函数