• Hi Tom and team,

    I have been using the free version of WPSP from quite a time and it does so many things well. I want to know if it is possible to use this plugin to create a widget (shortcodes will work too when placed in sidebar widget section) to display posts specifically from that category?

    For example if for someone reading my WPX hosting review article he should get related hosting and other host related articles on the sidebar while someone reading say a social media related post should get social media related posts on the sidebar.

    I have linked a site that has a similar setting in the sidebar (this is without thumbnails) in the secret link section of this topic.

    If this can be done in the pro version too, I would be more than glad to get it.

    Best regards,
    -Swadhin

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tom

    (@edge22)

    Hi there,

    This is only possible if you use the function to output the list. For example: https://wpshowposts.com/support/topic/automatic-filter-on-current-posts-category/#post-3806

    You could potentially build a shortcode like this:

    add_shortcode( 'category_list', function() {
        ob_start();
    
        if ( is_single() ) {
            $cats =  get_the_category();
            $cat = $cats[0];
        } else {
            $cat = get_category( get_query_var( 'cat' ) );
        }
    
        $cat_slug = $cat->slug;
    
        wpsp_display( 1, 'tax_term="' . $cat_slug . '"' );
    
        return ob_get_clean();
    } );
    Thread Starter Swadhin Agrawal

    (@iswadhin)

    Hi Tom,

    Thanks for replying. I went and checked out WPSP (the add new wpsp interface) and it didn’t have a place to add this snippet. Should I add it in the code snippets plugin?

    If yes, what do I need to do next (after adding it in the code snippet plugin?

    Plugin Author Tom

    (@edge22)

    Yes, the Code Snippets plugin is the way to use it.

    Once added, you can use this shortcode where you want the list to display:

    [category_list]

    Also, remember to change the 1 value in the wpsp_display() function to match the list ID you’re targeting.

    Thread Starter Swadhin Agrawal

    (@iswadhin)

    Thank you Tom,

    I think this will work for a specific category. What I wanted was a way to add a single widget (or shortcode) and it will automatically detect the post category (or the primary category in case there are 2 more more cats) and display posts from that category.

    Is this something doable (even in the premium version)?

    Plugin Author Tom

    (@edge22)

    That’s what that code does. It checks the current category and tells the list to pull posts from it.

    I’m a new user of WPSP, and a new user of generate press pro. Excellent stuff! The PHP code that you provided in this thread works great to build a ‘related posts’ list based on the category of the current post, thanks for sharing that. I’m hoping you can explain how it might be revised to use tags, too. Specifically, I want a list that shows posts that meet these criteria:

    Same category as the current post (which the code above already handles).
    *and*
    Has at least one tag in common with the current post.

    If this is possible, could you please explain or show how it can be done?

    Thanks!

    Plugin Author Tom

    (@edge22)

    Hi there,

    As of right now, I don’t believe this is possible.

    In our next version, the entire query will be filterable, so you’ll be able to get more advanced with your conditions.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sidebar widget’ is closed to new replies.