WordPress.org

Support

Support » How-To and Troubleshooting » Execute shortcodes in feed excerpt

Execute shortcodes in feed excerpt

  • Imagine a shortcode[1] that retrieves a link from a custom field and transforms a word or a phrase into an HTML formatted a element, so for example:

    Please, [link]check it out[/link] and let me know.

    will be transformed into:

    Please, <a href="http://wordpress.org">check it out</a> and let me know.

    This shortcode works fine in the content and in the feed content, but not in the feed excerpt, which will be outputted as:

    Please,  and let me know.

    clearing the part inside the shortcode.

    Is there a way to tell WordPress to execute this shortcode in feed excerpt? Or, better, how to tell WordPress to execute this shortcode in feed excerpt only if the post has a particular post format (‘link’, for example)?

    I make this question because some planets do not retrieve the complete feed content for each post but only the excerpt.

    Thanks in advance.
    Aldo

    [1] The shortcode I am using is this:

    add_shortcode( 'link', 'ubn_externalLinks' );
    
    function ubn_externalLinks( $atts, $content = null ) {
    	global $wp_query;
    
    	$output = '<a class="external" href="' . htmlspecialchars( get_post_meta( $wp_query->post->ID, 'External_links', true ) ) . '" rel="bookmark">' . $content . '</a>';
    
    	return $output;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Execute shortcodes in feed excerpt’ is closed to new replies.
Skip to toolbar