Skip to main content

Add custom Post “Meta Data” with Extra Fields

By default, post meta description is generated from post content. with “Extra Fields” plugin you can add custom meta that you can fill it manually.

First step, open “Extra Fields” plugin

Select “Post” content type then click “Load extra fields” > Add New

Fill like image above.

Add another one with key : “meta_keywords”

After extra fields created, go to “Posts” plugin page, then edit or create a new post, you will see extra fields in the right sidebar.

Fill it then save/publish.

Next, we need to add custom PHP code to show the extra fields, open “Theme Editor” plugin, then select “custom.php”

Put code bellow in custom.php

add_to_hook('head_top', function() {
	global $base_taxonomy;
	global $post;
	if($base_taxonomy == 'post'){
		if(isset($post)){
			$value = $post->getExtraField('meta_keywords');
		    if($value){
		        echo '<meta name="keywords" content="'.$value.'">';
		    }
		}
	}
});

Then save it.

What about the “meta_description” ? there is no code for it. Since CloudArcade v1.7.8, meta_description post Extra Fields will be used for “meta description” automatically, so you don’t need to create a custom code for it.