Add Schema Markup in WordPress Without Any Plugin

There is no doubt in this that WordPress is the worlds top Content Management System. The only reason most of the blogger love using WordPress because of its feature.
You can do whatever you want with WordPress if you’ve proper knowledge of plugins. WordPress has worlds’ largest database of plugin and themes.
In WordPress, Plugins available to customize it for the user. But sometimes these plugins create a headache and conflict with each other. Which lead to the decrease in our user experience.
In WordPress, There are hundreds of Schema markup plugin available to the user but they are not so user-friendly. Let’s Discuss Why?

Add Schema Markup in WordPress Without Any Plugin

Why Not Schema Plugin?

I Know What you’re thinking, If there are plugins available for schema markup why wouldn’t we use them.
According to me, I only use those things which increases my website performance and decreases work effort. If plugin decreases my effort that preferred it them and if individual code decreases my effort than I preferred them.
The main Problem With most of the plugins that they didn’t fix all Your Problem. Also, Plugin Fill Your Dashboard with too much setting that it overwhelming your brain.

Add Schema Markup Code

Follow Below Steps To add Schema Markup in Your Article Without any Plugin.
Step 1 – Go To Your Dashboard > Appearance > Editor and Find Single.php Mainly Named as Single post (as Shown In Below Image):


Step 2 – Once You found above file, Place below Code in its top.

<?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "thumbnail" ); ?>
<?php $image_width = $image_data[1]; ?>
<?php $image_height = $image_data[2]; ?>
<?php $custom_logo_id = get_theme_mod( 'custom_logo' ); ?>
<?php $logo = wp_get_attachment_image_src( $custom_logo_id , 'full' ); ?>
<?php $logo_width = $logo[1]; ?>
<?php $logo_height = $logo[2]; ?>
global $post;
<script type='application/ld+json'>{
"@context": "",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "<?php the_permalink(); ?>"
"headline": "<?php echo get_the_title( $post_id ); ?>","description": "<?php bloginfo('description'); ?>","datePublished": "<?php echo get_the_date(); ?>",
"dateModified": "<?php the_modified_date(); ?>","image": {
"@type": "ImageObject","url": "<?php the_post_thumbnail_url(); ?>",
"height":<?php echo $image_height; ?>,
"width":<?php echo $image_width; ?>},"publisher": {
"@type": "Organization",
"name": "<?php bloginfo( 'name' ); ?>",
"logo": {
"@type": "ImageObject",
"url": "<?php echo esc_url( $logo[0] ); ?>",
"width": <?php echo $logo_width; ?>,
"height": <?php echo $logo_height; ?>
},"author": {
"@type": "Person",
"name": "<?php
the_author_meta( 'user_nicename', $author_id );

All Done! Save Your Template.
Some things which you’ve to remember. According to Google Guidelines, these things must consider while writing a post.

  • Your Logo dimension Must not exceed 60px X 600px. Which means Height must not exceed 60px and width 600px.
  • You Featured Image Dimension Must larger than 800px X 800px.

Now Your Turn

Optimize Your Post for SEO by using above Schema markup code. It is easy to install and Use.
Once You install it then checks for errors in the Structured data testing tool. If you found one let me know In Comment. I’ll help you to fix it.

Leave a Reply

Your email address will not be published. Required fields are marked *