WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Need help running shortcodes on description (2 posts)

  1. mommysplurge
    Member
    Posted 10 months ago #

    Hi - I need assistance running shortcodes on the description in WP SEO. I'm using a custom field for the excerpt & inside that field are shortcodes that need to be run.
    http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-feature-request-apply-shortcodes-in-meta-description?replies=3
    does NOT work for me - it zaps my post (which also starts with that custom field!).

    I need to do SOMETHING to run those shortcodes. The function I have to create a custom excerpt works, and i use this shortcode in wp-views to create the excerpts on the home page. But I do not know a lot about filters, so I am sort of lost.

    Here's the shortcode function

    add_shortcode('review-excerpt', 'custom_excerpt_func');
    function custom_excerpt_func() {
      $post_excerpt = get_post_meta(get_the_ID(), 'wpcf-review-intro', true);
    $post_excerpt = preg_replace('/<img[^>]+\>/i', '',   $post_excerpt);
      $post_excerpt = do_shortcode($post_excerpt);
    $post_excerpt = apply_filters('the_excerpt', $post_excerpt );
     $excerpt_length = apply_filters('excerpt_length', 200);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
      return wp_trim_words( $post_excerpt, $excerpt_length, $excerpt_more );
    }

    http://wordpress.org/plugins/wordpress-seo/

  2. trixel
    Member
    Posted 6 months ago #

    try these, work for me

    /* Allow shortcodes in WP SEO meta description */

    add_filter('wpseo_metadesc', run_short_codes_in_meta_desc, 100);

    function run_short_codes_in_meta_desc($metadesc)
    {
    return do_shortcode($metadesc);
    }

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.