[Resolved] add action conditionally for a right sidebar heading

Home Forums Support [Resolved] add action conditionally for a right sidebar heading

Home Forums Support add action conditionally for a right sidebar heading

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #849651
    Elaine

    How do I add action conditionally for a right sidebar heading on Blog Archive & Single Posts?

    Using GP hooks, here is what I have so far, but this will show up in every right sidebar, and I have more than one. Interested in how to write it conditionally to only appear on Blog.

    add_action( ‘generate_before_right_sidebar_content’,’es_insert_title_right_sidebar’ );
    function es_insert_title_right_sidebar() { ?>
    <h4 class=”es-right-sidebar-title”>Filter Blog Posts</h4>
    <?php }

    GP Premium 1.7.8
    #849714
    David
    Staff
    Customer Support

    Hi there,

    you can use Conditional tags:

    https://docs.generatepress.com/article/using-hooks-conditional-tags/

    Or better still use the Hook Element which has the display rules built in:

    https://docs.generatepress.com/article/hooks-element-overview/

    I would go for the latter ๐Ÿ™‚

    #852850
    Elaine

    Thanks David
    I was able to add the heading in the right sidebar & a filter list menu under by applying the Widget Context plugin to an HTML widget and a Tag Cloud Widget. So the list menu is created from a Tag Cloud, in order to be able to filter Blog Posts.
    Now I am unhappy with the result in terms of the Breadcrumbs. If I click on a tag of ‘Mindset’ in the sidebar, instead of Breadcrumb: Home > Blog > Mindset, it appears Home > Mindset.
    Of course the url of that Post is: name-of-site/tag/mindset/. So I guess i’ve taken the Blog reference out of it altogether.
    How can I filter these Blog Posts so that I can maintain a Blog Breadcrumb logic?
    I’m using Tags, but would be in the same boat with Categories . . .?
    Thank you in advance for your help!

    #852856
    Elaine

    I forgot to mention I already have a Hook Element for Yoast Breadcrumbs activated for a location of ‘everywhere’.

    #852954
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not sure how to alter the output of the breadcrumbs themselves, unfortunately. That might be a question for Yoast support.

    This article might help: https://kb.yoast.com/kb/implement-wordpress-seo-breadcrumbs/

    I see there’s a “Show blog page” option you can select.

    #852993
    Elaine

    Thank you!

    #853643
    Tom
    Lead Developer
    Lead Developer
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.