• 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;
    	}

    http://wordpress.org/plugins/yet-another-related-posts-plugin/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author YARPP

    (@jeffparker)

    Hi kellbot. Just to be clear, are you saying that your shortcode for YARPP is displaying curly quotes on the screen?

    I took a quick glance at http://codex.wordpress.org/Shortcode_API and wanted to make sure you saw this:

    This means that your shortcode output HTML won’t automatically have curly quotes applied, p and br tags added, and so on. If you do want your shortcode output to be formatted, you should call wpautop() or wptexturize() directly when you return the output from your shortcode handler.

    I’m responding quickly so apologies if you’re aware of this.

    Thread Starter kellbot

    (@kellbot)

    Thanks for the quick response. To clarify: the filters don’t appear to be applied to the rest of the_content if I use the shortcode. The shortcode looks great. What’s really weird is that the rest of the content isn’t getting its curly quotes filtered out. I did a ton of testing, and the only difference between posts which appear correct (straight quotes) and incorrect (curly quotes) is the presence of my shortcode. If I comment out the call to yarpp_related() in the shortcode, quotes are once again straight as intended.

    The filter we’re using to remove curly quotes is Unfancy Quote. It’s dead simple.

    I know this is an off-label use, but I’m totally baffled by this behavior.

    Plugin Author YARPP

    (@jeffparker)

    Yes, it is both off-label and baffling. Maybe someone else has a similar story and can respond.

    Hi Kellbot,

    Sorry to sound stupid, from what I have read (if I have read it correctly), the code you posted above allows you add a shortcode on any page you wish which calls upon the plugin?

    If that is the case, what is the shortcode I would need to use?

    Many thanks

    Jack

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shortcodes and filters’ is closed to new replies.