Welcome Guest! Login? Checkout

Since I’ve recently been working on the site, one of the problems I’ve had and been trying to fix is the related posts appearing on the WordPress Plugins. I’ve been looking at ways to try and improve them, as this area has the highest traffic on the site, and I’m looking to try and get people to find what they are looking for easily, and not clutter up the pages. That’s why I’ve started adding documentation on a separate page, and hopefully getting people to get what they are interested in as quickly and easily as possible.

One thing I felt was cluttering up the area were the related posts section. Whilst I am a big fan of Jetpack’s Related Posts, I didn’t want them on every post, and whilst having a “you may be interested in” section may be useful, I’m not convinced it’ll be the most useful, so I’ve taken them off.

On the Customise Related Posts on Jetpack Related Posts, a Google search saw me trying to add Custom Post Types to the related posts, rather than removing the actual widget from elsewhere. Thankfully, a bit of modified code from another filter meant I fixed it.

To remove Jetpack related posts from custom post types, I use a filter, and a WordPress function.

The filter is jetpack_relatedposts_filter_options. This filter allows you to set and change the options on the fly should you wish. The second is the function is_singular. This native function of WordPress allows you to check if the current page is a single post of any post type. You can also pass the names of various post types as an attribute.

As such, I wanted to switch off related posts on all custom post types with the exception of blog posts. To do so, simply add this code:-

Place that code into your theme’s functions.php or in a plugin, and that should work for you.



Polite Disclaimer: I am welcome, open and willing for corrections to be shared in the comments (with corrections being added to posts and credited), and the comments field should be used to promote discussion and make this post better. I do not know everything and if anybody finds a better way to do something, then by all means please share it below.

However, I'm unable to offer support to posts. The reason being is that WordPress has tens of thousands of plugins and millions of themes. As such, finding out exactly why code doesn't work with your setup is a long process. If you wish for me to look at your code, please use the priority support area.

Comments asking support will be left on the site, but there is no guarantee of answer.

    Comments are closed.