• Resolved Roman

    (@vladroman)


    Hello!

    Recent Posts Widget With Thumbnails 7.1.1

    Just tested your plugin and very like it at all, but need special function.

    I need to show recent posts only for category (include all childs) of the current post (just its main category). This means list of recent posts will be different for posts from different categories.

    Can I do this with your plugin without directly editing its code?
    I didn’t find this in options. But maybe I can use any hooks for that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Roman

    (@vladroman)

    Checked your code. ??

    Looks like this will work for me.

    add_filter( 'rpwwt_widget_posts_args', 'rpwwt_change_category' );
    function rpwwt_change_category( $query_args ) {
        $current_cat_id = ... // A lot of code for getting value correctly. :)
    
        $query_args['cat'] = $current_cat_id;
        return $query_args;
    }

    Thank you for not fogetting to add filter in WP_Query request.

    Thread Starter Roman

    (@vladroman)

    Just now a small problem – this works at same time for all widgest, created by your plugin. ??

    If I want to use more than 1 widget with recent posts, but only 1 with current category post list, this become a problem.

    Any solution? ??

    Plugin Author Kybernetik Services

    (@kybernetikservices)

    Hello @vladroman .

    Thank you for reaching out.
    I’m happy you found the solution by yourself.
    Regarding your “small problem”: There is no build in solution. I can imagine to add a conditional statement in the function for the filter to modify the category id only for a specific widget, based on the $query_args.

    I am sorry that I cannot help with a better solution.

    Thread Starter Roman

    (@vladroman)

    Yeah, I did like that. Modification works only for specific post type.

    Anyway, maybe somewhen you will find time and add to your plugin option for filter recent posts by current category. This will be great! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Posts from current category’ is closed to new replies.