• Resolved webstorme

    (@webstorme)


    Pre Usage Question. I was able (via some function code) to get Yoast SEO to accept shortcodes in Titles and Description. This is a critical need for our consultant websites. This plugin sounds very cool, but before I can look at implementing it I need to know – Will your plugin accept shortcodes in page/post Titles/Descriptions. Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Thank you for considering TSF ??

    Yes, we’ve thought ahead in that, but it’s a non-standard feature. You’ll have to insert two tiny filters on your website. Pick the ones that apply to your website.

    Either, when using WP 5.4 or higher:

    add_filter( 'the_seo_framework_title_from_custom_field', 'apply_shortcodes' );
    add_filter( 'the_seo_framework_custom_field_description', 'apply_shortcodes' );

    Or, when using WP 2.5 or higher (also works on WP 5.4):

    add_filter( 'the_seo_framework_title_from_custom_field', 'do_shortcode' );
    add_filter( 'the_seo_framework_custom_field_description', 'do_shortcode' );

    Either of those filters will enable shortcode processing when you manually input them in the TSF-supplied SEO-meta fields.

    Please note that shortcodes from your content and page-titles won’t be considered for auto-generation of descriptions. You can enable that, however, with these filters:

    // Disable stripping of shortcodes in description generation.
    add_filter( 'the_seo_framework_allow_excerpt_shortcode_tags', '__return_true' );
    
    // do_shortcode, or optionally use apply_shortcodes WP 5.4+
    add_filter( 'the_seo_framework_fetched_description_excerpt', 'do_shortcode' );
    add_filter( 'the_seo_framework_title_from_generation', 'do_shortcode' );
    

    Please note that the shortcode output can get cached via object-caching, and I, for security reasons, do not recommend using the last snippet unless you’re certain the shortcodes won’t output sensitive (user) information.

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode In Titles And Description’ is closed to new replies.