WordPress knowledge sharing

How can I add bread crumbs to the GeneratePress theme?

In this article, Lao Wei will teach you how to Add bread crumbs to the GeneratePress theme The need for website breadcrumbs comes before WordPress bread crumb plug-in The content has already been explained. The GeneratePress theme is a foreign theme. It is simple to operate and easy to use. Its main features are extremely fast speed and strong performance. It is popular with WordPress webmasters. The GeneratePress theme itself does not provide bread crumbs, and can only be added by the following methods.

In the example in this article, Lao Wei uses GeneratePress theme and GP Premium plug-in , see this link for details. At present, hundreds of thousands of users have activated it. The GP Premium plug-in is an advanced version of the GeneratePress theme, which provides elements, website libraries and other advanced functions. Interested in going GeneratePress Theme Website have a look. After using it, Lao Wei felt that it was much simpler than the Avada theme, and logically easier to learn and master.

Many seo plug-ins provide the breadcrumb function. We just need to enable this function and add the breadcrumb code.

Two core 4G memory and 3M bandwidth are selected for the theme and plug-in of foreign website construction, which can run smoothly.
Domestic servers: Alibaba Cloud Tencent Cloud (All have vouchers, which can be used to save money when paying), I don't know how to select regions and configurations. Please add Lao Wei's contact information on the right side of the page. Let's study it together.

Foreign trade websites, B2C/C2C, etc. suggest registering domain names abroad. open Namesilo official website , enter the domain name to be registered in the search box, select it and then register. Remember to use the discount code to save money before paying. Discount code click Course of domain name registration of foreign domain name provider Namesilo obtain.

Suggested choice of foreign trade website Hostinger virtual host , the price is cheap and the performance price ratio is very high! Hostinger topic
SiteGround virtual host Moderate price, good service! SiteGround Theme

Yoast SEO adds bread crumbs to the GeneratePress theme

1. After enabling the Yoast SEO plug-in( Yoast SEO Plug in English Setting Tutorial ), find SEO>search appearance>breadcrumb navigation at the bottom left of WordPress dashboard, and start setting.

Enable path navigation, activate. There is basically no need to change the following;

In the breadcrumb navigation, select "Category Catalog" for the article type.

Save changes.

 Yoast SEO enable bread crumbs

Yoast SEO enable bread crumbs

2. In GeneratePress Theme>Appearance>Elements>Add New Element>Select the Hook type, name it, and add the following code:

<? php if ( function_exists(‘yoast_breadcrumb’) ) { ?>
<div class=”grid-container grid-parent”>
<div class=”page-header”>
<? php yoast_breadcrumb(‘<p id=”breadcrumbs”>’,'</p>’); ?>

</div>
</div>
<? php } ?>

Lao Wei tips: If the static home page is set, use the following code , including disabling bread crumbs on the home page. Using the above code will lead to bread crumbs on the home page.

<? php if ( function_exists(‘yoast_breadcrumb’) && ! is_front_page() ) : ?>
<div class=”grid-container grid-parent”>
<div class=”page-header”>
<? php yoast_breadcrumb(‘<p id=”breadcrumbs”>’,'</p>’); ?>

</div>
</div>
<? php endif; ?>

In fact, there is only more home page judgment than the first piece of code.

3. The following figure shows the process of adding the above code. This website has a static home page, so Lao Wei uses the code to determine whether it is the home page.

  • Naming;
  • Paste code;
  • Select the effective location of hook, before content;
  • Check Execute php.
  • Display rule: All Singular (lazy without screenshot);
  • Publish.
 GeneratePress Theme Add Breadcrumb Code

GeneratePress Theme Add Breadcrumb Code

You can also add css style to the bread crumbs generated above according to your personal needs. If not, it is very plain. Old Wei thinks that the general style is also very good.

Rank Math adds bread crumbs to the GeneratePress theme

1. Rank Math plug-in and Yoast SEO plug-in are both very popular seo plug-ins in the world of WordPress, Using the Rank Math plug-in The advantage is that you can get most of the advanced functions of the Yoast SEO plug-in for free. This is why many bloggers strongly recommend it.

2. After installing the enable Rank Math plug-in on the WordPress dashboard, enter Rank Math>General Settings>Breadcrumbs, turn on the Enable breadcrumbs function switch (forgot to mark it in the picture), and enable the breadcrumbs function.

Then copy the breadcrumb code or simplified code provided by Rank Math, that is,<? php ?> The code in that line and the simplified code in the second line can also be used. For the convenience of identification, put the code and simplified code below, and choose one from the other.

<? php if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); ?>
or
[rank_math_breadcrumb]

 Rank Math adds bread crumbs to the GeneratePress theme

Rank Math adds bread crumbs to the GeneratePress theme

3. The options here are basically unchanged. Lao Wei summarized three items that may need to be customized as follows:

  • Separator Character: the first one by default or selected according to personal preference;
  • Homepage label: the first label of bread crumbs. The default is Home. Someone uses the website name;
  • Hide Post Title: Hide the title of the article with bread crumbs. For example, on the article page of Weiaisi's notes, the article title in bread crumbs was replaced by "body". This is the same as the title. It is suggested to open it;
  • Show Category (s): If the category is a subcategory, all ancestor categories will be displayed. For example, if the category is divided into two levels, it will display: Home>Parent Category>Category>Article. The display path is reasonable, and it is recommended to open it;
  • Hide Taxonomy Name: Hides the taxonomy name in bread crumbs. Taxonomy includes category and tag, which are not displayed after being opened;
  • You can select the above three options to see the effect of the foreground page, and then make the final settings.

4. In WordPress Dashboard>Appearance>Element>Add New Element>Select Element Type: Hook, as shown in the following figure:

  • Give a name;
  • Choose Element Type Choose Hook;
  • Paste the code or simplified code copied above;
  • Select before content from the hook in setting;
  • Execute php: check;
  • Display rule: All Singular (lazy without screenshot);
  • Click Update and Save on the right;
 GeneratePress Theme Add Breadcrumb Hook

GeneratePress Theme Add Breadcrumb Hook

In other cases, add bread crumbs in GeneratePress

1. If you use the free All in One SEO package plug-in, do not use any seo plug-in, and the theme does not provide bread crumbs, you need to Using the Breadcrumb NavXT plug-in

2. Similar to the operation of the seo plug-in above, add hooks in the WordPress dashboard.

3. Paste the following contents into the hook:

<div class=”breadcrumbs”>
<? php
if(function_exists(‘bcn_display’))
{
bcn_display();
}?>
</div>

Publish hook.

4. In addition, by default, the first label of the breadcrumb title is the site name in Settings>General. For convenience, you can use the following code to change the name of the "site title" in the breadcrumb to "home page".

To achieve this goal Install and use the Code Snippets plug-in

After installation and enabling, add new fragments in the plug-in, copy and paste the following code to activate.

add_filter(‘bcn_breadcrumb_title’, ‘my_breadcrumb_title_swapper’, 3, 10);
function my_breadcrumb_title_swapper($title, $type, $id)
{
if(in_array(‘home’, $type))
{
$title = __(‘Home’);
}
return $title;
}

The first label of bread crumbs will display "Home". Chinese websites can be changed into "home page" in Chinese.

Lao Wei's comments

This article mainly introduces GeneratePress Theme Add Breadcrumbs Method. Including the use of Yoast SEO plug-in and Rank Math plug-in. If you use the GeneratePress theme, most websites should add a seo plug-in. Even if you do not use the seo plug-in or use the seo plug-in but do not support bread crumbs, you can find the corresponding operation methods in this article. It's not easy to write. If you like this article or it helps you, please follow Weieis' notes and share them.

Like( three )
Article name: How to add bread crumbs to the GeneratePress theme
Article link: https://www.vpsss.net/23863.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.