Site logo

Archived topic

add action conditionally for a right sidebar heading

6 replies · Started by Elaine on March 25, 2019

Viewing posts 1–7 of 7

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 }

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!

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

Thank you!

You're welcome :)

This archived topic is closed to new replies.