• Resolved David181

    (@david181)


    Hi there,

    is it possible to show the meta description on a page as text? So inserting the meta description as text into a footer, for example?

    Are shortcodes available?

    Thanks and best,
    David

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

    (@cybr)

    Hi again, David,

    There’s an API available, so you can create your personalized shortcodes 🙂

    Here’s the code that you’d want to implement, like in your child-theme’s functions.php file, or a custom plugin:

    add_shortcode( 'tsf-description', function( $atts ) {
    
    	$atts = shortcode_atts( [
    		'id'       => null,
    		'taxonomy' => '',
    	], $atts );
    
    	if ( function_exists( 'the_seo_framework' ) ) {
    		$args = null;
    
    		if ( isset( $atts['id'] ) ) {
    			$args = [
    				'id'       => $atts['id'],
    				'taxonomy' => $atts['taxonomy'],
    			];
    		}
    
    		return esc_html( the_seo_framework()->get_description( $args ) );
    	}
    
    	return '';
    } );

    And here are some example shortcodes that work with it:

    1: [tsf-description] // Gets current query description.
    2: [tsf-description id=1] // Description from page/post ID 1.
    3: [tsf-description id=1 taxonomy=category] // Description from category ID 1

    I hope this is useful! Cheers 🙂

    Thread Starter David181

    (@david181)

    Hi @cybr,

    works perfectly and as expected.
    Thanks for your help!

    Thanks and best,
    David

    • This reply was modified 7 years ago by David181.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Shortcode to display meta description as text?’ is closed to new replies.