[Support request] Adding a sidebar that contains links at posts in same category

Home Forums Support [Support request] Adding a sidebar that contains links at posts in same category

Home Forums Support Adding a sidebar that contains links at posts in same category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #999011
    James

    Hello:

    I want to add a right hand side bar on all my post pages. This sidebar needs to contain links to other articles in the category.

    In order to do this, I have changed the settings in customise/ layout/ sidebar menu and I have added a new category post element which confuses me a bit because under display rules/ location I have selected the post category from the drop down menu but then another drop down menu appears containing a list of all of my categories to choose from.

    I don’t understand. Why do I need to select individual categories?

    #999053
    David
    Staff
    Customer Support

    Hi there,

    If you want to display Posts of the Same Category on each of your single posts you will need a plugin like this:

    https://en-gb.wordpress.org/plugins/same-category-posts/

    It provides you with a Same Category Post widget you can add to your sidebar. Then just set the Sidebar to be displayed on posts within the Customizer.

    The Display Rules in Elements are solely for adding/changing that specific element, it won’t effect how a widget in a sidebar filters the recent posts for example.

    #1854680
    Scott

    How would I add this to the bottom of our blog posts so that it displays the 3 most current blogs of a certain category on the bottom of all posts within that category?
    For Instance: post “Best PPC Practices” in category “PPC”
    below the post content, display a 3 column (on desktop/1 column on mobile) showing the 3 most recent posts within the category PPC. I installed Same Category Posts plugin. Just not sure how to get it at the bottom of the post pages.
    Thanks!!

    #1854947
    Elvin
    Staff
    Customer Support

    Hi Scott,

    David’s recommended plugin was for post listing on the sidebar.

    If you need to display related posts in a column, you’ll need a post list plugin for that.

    You can try WP Show Posts – https://wpshowposts.com/ – to create the post list in columns.

    You then add this PHP snippet.

    add_shortcode('dynamic_wpsp', function($atts){
        $queriedArchive = get_queried_object();
        $atts = shortcode_atts( array(
    			'id' => ''
    		), $atts, 'dynamic_wpsp' );
    
        $settings = array(
            'taxonomy' => $queriedArchive->taxonomy,
            'tax_term' => $queriedArchive->slug,
        );
     
        ob_start();
        wpsp_display( $atts['id'], $settings );
        return ob_get_clean();
    });

    And then hook in the shortcode [dynamic_wpsp id=”1234″] where 1234 is the WPSP list id.

    You can use a Hook Element to hook the shortcode in. Set the Hook Element’s hook to generate_after_main_content with display rule location set to “Post – all posts” so it only displays on the bottom single posts pages. 😀

    A wise man once said:
    "Have you cleared your cache?"

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.