• Resolved inicslab

    (@inicslab)


    Hi, I know there is a way to filter posts from top posts, but is there a way in which i can exclude categories from Top posts on the widget

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor csonnek

    (@csonnek)

    Happiness Rocketeer 🚀

    Hi there:

    We do have a filter for that – you can find the filter and an example on how to implement that on this page:

    https://developer.jetpack.com/hooks/jetpack_widget_get_top_posts/

    In the example, you would need to find the post IDs of all the posts in the category that you want to exclude and use the filter to filter them out. You could also modify the example to filter out by category slug instead of post ID. You can experiment with the best way to implement that filter to work how you’d like.

    I hope that helps!

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    You can follow the example at the bottom of the page Carolyn mentionned earlier.

    There, you can use the in_category() function to check if each post ID belongs to a specific category, and then unset it if it does:
    https://developer.wordpress.org/reference/functions/in_category/

    I hope this helps.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Exclude Top post by category’ is closed to new replies.