• Tried the the_advanced_excerpt() but it outputs &hellip only. Basically wants to call the excerpt for “description”:”Call the excerpt”.

    Any suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WPKube

    (@wpkube)

    Hi @deepaktiwari

    I’m not quite sure I understood what is needed.

    From what I understood you tried placing the_advanced_excerpt() function somewhere but it hasn’t worked out the way you want it. But I’m not sure about the specifics.

    Can you share the few lines of code in that are where you placed the shortcode, should help me understand what’s the issue.

    Thread Starter Deepak T

    (@deepaktiwari)

    Hello,

    I’m trying to call excerpt for the pages"description": "Call The Excerpt Here", but we’re using this plugin and I’m unable to call default short description of the pages.

    In the plugin detail page, I saw the function the_advanced_excerpt() with some filters which didn’t work.

    Below is the JSON-ld code and in place of description I need to call short description of the page.

    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "WebPage",
        "name": "CallTitle",
        "description": "Call The Excerpt Here",
        "publisher": {
            "@type": "PageType",
            "name": "AutherName"
        }
    }
    </script>
    Plugin Author WPKube

    (@wpkube)

    Hi @deepaktiwari

    That is in functions.php as part of a hook to wp_head (or wp_footer), correct?

    Here’s the code:

    <script type="application/ld+json">
    {
    	"@context": "https://schema.org",
    	"@type": "WebPage",
    	"name": "CallTitle",
    	"description": "<?php echo esc_attr( esc_html( get_the_excerpt() ) ); ?>",
    	"publisher": {
    		"@type": "PageType",
    		"name": "AutherName"
    	}
    }
    </script>

    The esc_html() gets rid of HTML since that’s not allowed in the schema markup, the esc_attr() makes sure that things don’t break, like for example if there is a ” in the excerpt.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I call excerpt for schema markup in functions.php file?’ is closed to new replies.