How to add breadcrumb in wordpress

in #utopian-io7 years ago (edited)

breadcrumb.png

What Will I Learn?

  • You will learn how to add a breadcrumb to your website / blog or online store.
  • You will learn how to change the breadcrumb that comes by default.

Requirements

  • Need to have the CMS Wordpress platform plugin.
  • Plugin installed and activated from TablePress.
  • Code editor.
  • Understand some of the PHP language.

Difficulty

  • Basic

Tutorial Contents

This plugin is very useful to tell the user which page you are on. On quite extensive sites where there are quite a few subpages it is very helpful to have the path covered to know where you are.

After having installed and activated the plugin it is necessary to put a line of code in our theme header.php

So we have to go to:

  1. Go to the menu "Appearance"
  2. Click in submenu "Editor"
  3. Click in Theme Files > Theme Header (Header.php)
  4. Put this string of code below:
<? php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ? >

1.JPG

Save the theme and after this step already has the breadcrumb on your site.

Now I will configure the breadcrumb to my liking and explain the rows of the settings.
If we go to the code of our project. We have to go to the folder where we installed wordpress.

MyFolder > wp-content > plugins > breadcrumb-trail > inc > breadcrumbs.php
My folder: This is the place where I installed wordpress for this project.

3.JPG

We have to find this section of code in file breadcrumbs.php:


    $defaults = array(
            'container'       => 'nav',
            'before'          => '(',
            'after'           => ')',
            'browse_tag'      => 'h1',
            'list_tag'        => 'ul',
            'item_tag'        => 'li',
            'show_on_front'   => true,
            'network'         => false,
            'show_title'      => true,
            'show_browse'     => true,
            'labels'          => array(),
            'post_taxonomy'   => array(),
            'echo'            => true
        );

In these parameters I'm just putting a "(" before the breadcrumbs and a ")" after. However, if you want you can change the settings of the other parameters and check how it is on your site.

If we want to change more things in our breadcrumbs we have to find this piece of code in same page breadcrumbs.php .


$defaults = array(
            'browse'              => esc_html__( 'Test:', 'breadcrumb-trail' ),
            'aria_label'          => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'breadcrumb-trail' ),
            'home'                => esc_html__( 'Home', 'breadcrumb-trail' ),
            'error_404'           => esc_html__( '404 Not Found', 'breadcrumb-trail' ),
            'archives'            => esc_html__( 'Archives', 'breadcrumb-trail' ),
            // Translators: %s is the search query.
            'search'              => esc_html__( 'Search results for: %s', 'breadcrumb-trail' ),
            // Translators: %s is the page number.
            'paged'               => esc_html__( 'Page %s', 'breadcrumb-trail' ),
            // Translators: %s is the page number.
            'paged_comments'      => esc_html__( 'Comment Page %s', 'breadcrumb-trail' ),
            // Translators: Minute archive title. %s is the minute time format.
            'archive_minute'      => esc_html__( 'Minute %s', 'breadcrumb-trail' ),
            // Translators: Weekly archive title. %s is the week date format.
            'archive_week'        => esc_html__( 'Week %s',  'breadcrumb-trail' ),
            // "%s" is replaced with the translated date/time format.
            'archive_minute_hour' => '%s',
            'archive_hour'        => '%s',
            'archive_day'         => '%s',
            'archive_month'       => '%s',
            'archive_year'        => '%s',
        );

In this piece of code I just changed to test to check how it appears in breadcrumb.

2.JPG

As you can see our breadcrumb I am in the format of (test: page1 / page2).

If for example you want to modify the separator between the pages you have to go to:
MyFolder > wp-content > plugins > breadcrumb-trail > breadcrumb-trail.php

4.JPG

Find these lines of code:


.trail-items li::after {
    content: "\002F";
    padding: 0 0.5em;
 }

Change de code line content:


content: "\003e";

Now it will look like this:
5.JPG

This plugin is handy to use however you need to understand a little bit of the PHP language if you want to predefine your breadcrumb.

Curriculum

In my curriculum find tutorials on wordpress as it is my daily work tool. Many more will be made.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

I always try to support who contribute to open source project, upvote you.

Thank you for your words of support.

Hey @portugalcoin I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63608.16
ETH 2621.61
USDT 1.00
SBD 2.77