How to move related output from content to after post
-
The official recommendation will not work, don’t even bother.
If you want to move the related group of links fron the end of post content to the outside of the post content, use a later hook.
You can put exactly this snippet into you theme’s functions.php://push related post insertion point after post content //first we remove the hook from the tail end of content global $related; remove_filter( 'the_content', array($related, 'related_content_filter') ); // then we hang related on a later hook add_action( 'post_content_after', 'related_content_filter' ); function related_content_filter( ) { if ( (get_option( 'related_content', 0 ) == 1 && is_singular()) || get_option( 'related_content_all', 0 ) == 1 ) { global $related; $related_posts = $related->show( get_the_ID() ); if ( $related_posts ) { $output = '<div class="related_content" style="clear:both;">'; $output .= '<h3 class="widget-title">'; $filtered_title = stripslashes(get_option('related_content_title', __('Related Posts', 'related'))); $output .= apply_filters( 'related_content_title', $filtered_title ); $output .= '</h3>'; $output .= $related_posts; $output .= '</div>'; echo $output; } } // otherwise returns nothing return ; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to move related output from content to after post’ is closed to new replies.