• Resolved empirehive

    (@empirehive)


    Hi,

    While browsing the net I came across a site with a feature I would love to have on my own blog.

    I’m hoping you could show me how to create a category breadcrumb-like element as on the site in the top left corner of the posts.

    (I’m not sure if this question is for the GeneratePress or the WP Show Posts forum)

    You can view the site here.

    Thank you for your time!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    Are we talking about this link?: https://www.screencast.com/t/TruDhcjvL7E

    Let me know ??

    Thread Starter empirehive

    (@empirehive)

    Yes sir ??

    Theme Author Tom

    (@edge22)

    Those are the categories.

    You can move them up above the title with this function:

    add_filter( 'generate_show_categories', '__return_false' );
    add_action( 'generate_before_content', function() {
        if ( ! is_single() ) {
            return;
        }
    
        $categories_list = get_the_category_list( ' ' );
    
        if ( $categories_list ) {
            printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
                _x( 'Categories', 'Used before category names.', 'generatepress' ),
                $categories_list
            );
        }
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Then you can style them with some CSS:

    .cat-links:before {
        display: none;
    }
    
    .cat-links a {
        display: inline-block;
        padding: 3px 6px;
        background: #000;
        color: #fff;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    Hope this helps ??

    Thread Starter empirehive

    (@empirehive)

    Thanks Tom,

    Working as intended ??

    Theme Author Tom

    (@edge22)

    Glad I could help ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add category breadcrumb’ is closed to new replies.