WordPress.org

Ready to get started?Download WordPress

Forums

Execute shortcodes in feed excerpt (4 posts)

  1. aldolat
    Member
    Posted 3 years ago #

    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;
    }
  2. rlgrobert
    Member
    Posted 2 years ago #

    Hello, did you ever find a solution for this? I need to do the same thing.

  3. aldolat
    Member
    Posted 2 years ago #

    Hello,
    No, I didn't. :(
    I should take a look into the function that creates the excerpt, but for now I do not have much time available.

    I the case I resolve it, I will inform you here.

  4. aldolat
    Member
    Posted 2 years ago #

    rlgrobert,
    try this plugin: http://wordpress.org/extend/plugins/advanced-excerpt/

    It should fit your needs.

Topic Closed

This topic has been closed to new replies.

About this Topic