Shortcodes and filters
-
We use YARPP along with a filter on the_content to insert links to related posts in the middle of our articles. I realize from reading this forums that this may potentially lead to some problems with infinite loops, but so far this has worked beautifully for us. We have over 4000 posts and it is working great (thank god for caching).
I also made a shortcode to use when we want to place the links precisely in the content. Those work great except for one curious bug: our filters which change curly quotes to uncurly quotes aren’t applied if we use the shortcode.
I can probably live with the curly quotes, but I’m concerned this may be hinting at a more serious problem.
Here’s the shortcode source. I confirmed the problem isn’t specific to our template, even with a blank template the quotes filter is getting missed.
function obe_yarpp_shortcode($atts){ //exclude from feeds and archives if (!is_single()) return ''; global $yarp_align; $yarp_align = 'align' . $atts['align']; $related_post = yarpp_related(array( 'threshold' => 5, 'template' => 'yarpp-template-inline.php', 'limit' => 1 // maximum number of results ), null, false); return $related_post; }
https://www.ads-software.com/plugins/yet-another-related-posts-plugin/
- The topic ‘Shortcodes and filters’ is closed to new replies.