Hi there,
This is the only post that currently have that tag correct?:
https://revistausina.com/serie/colecao-nana-nelson-angelo-novelli/
I currently do see related posts as well.
If you going by the template on the customize related posts page, I would try:
function jetpackme_no_related_posts( $options ) {
if ( has_tag( 'n-relacionar' ) ) {
$options['enabled'] = false;
}
return $options;
}
add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_no_related_posts' );
Have you tried that starting point to see if that worked?
Let me know if that doesn’t work, and I will look further into this for you.
Hey, yes. That’s what I added to my functions.php, but it’s not working. I would like to have several posts tagged ‘n-relacionar’, which would be easier for me than looking for the post id and uptading to is_single conditional…
Thanks for the help
Hey! I have also tried to add the is_single conditional snippet but it doesn’t work as well. Here is the code I used:
function jetpackme_no_related_posts( $options ) {
if ( is_single( array( 8034, 7884, 7844, 7770, 8444, 10391, 7936, 8983, 10385, 8047, 8040, 9096, 9450, 9452, 10056, 9497, 10131, 10330 ) ) ) {
$options['enabled'] = false;
}
return $options;
}
add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_no_related_posts' );
Does anyone know why?
Thanks
Hi @revistausina,
I’ve had a look at the examples you shared and can’t see any issues there. If none of the conditional tags are working (is_single
or has_tag
), that points to a broader issue with your code or perhaps the placement in your functions.php file.
As the Customize Related Posts page mentions, we provide these snippets but are unable to offer assistance in customising them further. Someone else may be able to chime in with a suggestion but otherwise, you may need to ask a developer to have a closer look at why it isn’t working within the code you already have.
Thanks Gemma, I will try to find someone to check my functions.php then. I wasn’t really trying to customize them further, but only to understand why they don’t work, since the code is right
The problem is that all other functions inside functions.php work, including a couple from JetPack, for example’jetpackme_more_related_posts’ and ‘jeherve_custom_image’. Only this ‘jetpackme_no_related_posts’ doesn’t work…
Are you sure you have added it as Darnell described earlier? https://wordpress.org/support/topic/conditional-tag-for-related-posts-not-working/#post-11364132
jetpackme_no_related_posts
isn’t a function in Jetpack, adding the filter is what creates the function.