• Resolved jd1234

    (@jd1234)


    Hi,

    Great plugin.

    The about-us and contact-us page description is wrong.

    I am following the plugins documentation and collecting description and headline from yoast seo for posts but for about us and contact us page its not getting the right data as I have disabled Schema for pages. I am enabling schema for about us and contact us pages through the plugins setting page.

    Would appreciate if you can shed some light on it.

    https://search.google.com/structured-data/testing-tool/u/0/#url=rezaid.co.uk%2Fabout-us%2F

    • This topic was modified 6 years, 3 months ago by jd1234.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jd1234

    (@jd1234)

    Is there a code that I can use to over-write the schema output?

    Just the description in About and contact page is wrong.

    Thread Starter jd1234

    (@jd1234)

    Does this code also works for:

    -ContactPage
    -AboutPage

    The description of my contactpage and aboutpage is wrong.

    add_filter( 'schema_output', 'schema_wp_override_description_yoast_seo_12345' );
    /*
    *	Override Schema description value with Yoast SEO description
    */
    function schema_wp_override_description_yoast_seo_12345( $schema_output ) {
    	
    	// get description value from Yoast SEO post meta
    	$desc = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true);
    	
    	// override the value in schema output
    	$schema_output["description"] = $desc;
    	
    	// return our schema array
    	return $schema_output;
    }
    Plugin Author Hesham Zebida

    (@hishaman)

    The code you’ve shared will work only on singular pages, we will need to use another filters for the About and Contact page, I’ve modified the code on the documentation page.

    So, the code should be something like this:

    add_filter( 'schema_output', 'schema_wp_override_description_yoast_seo_5636346455' );
    add_filter( 'schema_about_page_output', 'schema_wp_override_description_yoast_seo_5636346455' );
    add_filter( 'schema_contact_page_output', 'schema_wp_override_description_yoast_seo_5636346455' );
    /*
    *	Pull Schema Title and Description values from Yoast SEO 
    */
    function schema_wp_override_description_yoast_seo_5636346455( $schema_output ) {
    	
      // get Title (Headline) value from Yoast SEO post meta
    	$headline = get_post_meta( get_the_ID(), '_yoast_wpseo_title', true);
    	
    	// get Description value from Yoast SEO post meta
    	$desc = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true);
    	
    	// override the values in schema output
    	$schema_output["headline"]    = $headline;
    	$schema_output["description"] = $desc;
    	
    	// return our schema array
    	return $schema_output;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘About us and contact us description is wrong’ is closed to new replies.