Kategorien
Technical

How to add a metadescription to wordpress without plugin

First: Enable Custom Fields. Go to any Blogpost and click right on the 3 dots

Then enable „Custom fields“

Click on „enter new“

as key use, what you want to add as key later in the tempalte code like „metadescription“

then got into your theme, eg ../wp-content/themes/mytheme#

search for your header eg header.php and add this code on top


<?php 

$description = get_post_meta($post->ID, 'metadescription', true); 
if (isset($description) && ($description != "") ){
	echo "<meta name=\"description\" content=\"".get_post_meta($post->ID, 'metadescription', true)."\"/>"; 
}

?>

It checks if the field is given and only then it adds the metadescription field to the code of the page

otherwise not.

BTW: Hummingbird-Cache files under

/var/www/html/wp-content/wphb-cache/cache/www.domain.com/pageurl/