Hi Michael,
It’s not something currently offered, exactly, but I did find a suggestion for you in this thread.
We haven’t tested this specifically, but in JP 3.0, there is a shortcode for related posts now.
As long as it is within the Loop, something like `do_shortcode( ‘[jetpack-related-posts]’); and unhooking the original filter should work in theory.
Let us know if that helps!
Hi lettergrade!
Thank you so much for your reply!
Just one problem: I don’t have a clue on how to unhook the original filter! 😛
I’ve looked in the source code:
https://github.com/Automattic/jetpack/blob/master/modules/related-posts/jetpack-related-posts.php
And in the Codex:
http://codex.wordpress.org/Function_Reference/remove_filter
But I’m to much of a n00b to make sense of it….
I tried something like this:
function ap_remove_related_posts() {
remove_filter( 'the_content', 'filter_add_target_to_dom',19 );
}
add_action( 'wp', 'ap_remove_related_posts' );
And this:
function ap_remove_related_posts() {
remove_filter( 'the_content', 'action_frontend_init',10 );
}
add_action( 'loop_start', 'ap_remove_related_posts' );
And several variants.
Nothing helps. It’s just a guessing game for me…
Anyone out there who is a bit more knowledgeable about these things? 😛
You’re really close.
function remove_jprp(){
$jprp = Jetpack_RelatedPosts::init();
remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' ), 40 );
}
add_action('wp', 'remove_jprp', 11);
Since Related Posts is a singleton, we can call it up again and it’ll return the same instance we already have. We have to call it in the remove_filter since the filter_add_target_to_dom
is a function with the Jetpack_RelatedPosts
class and so not generally available.
We need to match the priority levels, so 40.
On the add_action
, we need to make sure we call it after the initial add_filter had been thrown in to the mix. Adding it directly to the wp hook at priority 11 takes cares of us.
Cheers!
Hi Brandon,
Better late then sorry I guess: but thank you! It worked perfectly!
Best regards,
Michael