how to get meta description value for schema

#515451
  • Resolved M Javad Koushki
    Rank Math free

    Hello. I need to get value of content in meta description to display it in schema code
    https://freeimage.host/i/HcA38Rp
    what code I can replace with <?php the_excerpt(); ?> to display right descriotion as in above image?

    
          "@context": "https://schema.org",
          "@type": "NewsArticle",
          "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https://google.com/article"
          }, 
          "headline": "<?php the_title(); ?>",
    	  "description": "<?php the_excerpt(); ?>",
          "image": "<?php if(get_post_meta($post->ID, 'echo_featured_img', true)) { $img = get_post_meta($post->ID, 'echo_featured_img', true); echo $img; } if(get_post_meta($post->ID, 'echo_featured_img2', true)) {$img2 = get_post_meta($post->ID, 'echo_featured_img2', true); echo $img2; }?>",
          "datePublished": "<?php the_date('Y/m/d'); ?>",
          "dateModified": "<?php the_modified_time('Y/m/d'); ?>",
          "author": {
            "@type": "Person",
            "name": "<?php the_author(); ?>",
            "url": "<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"
          },
          "publisher": {
            "@type": "Organization",
            "name": "Akhbarejadid",
            "logo": {
              "@type": "ImageObject",
              "url": "https://akhbarejadid.com/wp-content/uploads/2021/05/logoakhbarejadid.png"
            }
          }
        }
    
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘how to get meta description value for schema’ is closed to new replies.