[Support request] Automatic filter on current post's category

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Automatic filter on current post's category

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3780
    Benjamin
    Participant

    Hey Tom,

    I would love the plugin to have an automatic filter on the current post category (to show all posts of the same category without having to create 1 list for each category which is a pita).

    To avoid issues the plugin would filter on the first category it finds if the post has multiple categories (who’s doing that on purpose these days anyway…).

    The goal for me (so you understand what I’m trying to achieve) is to configure ONLY 2 posts lists :
    – 1 list showing the 5 first posts of the same category as the current post in 1 column in the right sidebar
    – 1 list showing the 3 next posts (offset of 5) of the same category as the current post in 3 columns below the post content

    This way I could achieve some kind of “magazine” layout on all my posts page by only having to configure 2 lists with dynamic “auto category filtering”.

    Cheers,

    #3806
    Tom
    Keymaster

    Hi there,

    You can add custom parameters to the shortcode, like this:

    <?php
    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 . '"' );
    ?>

    That will only show posts from the same category which is currently being viewed.

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