open
09.08.2022.

Automatic filling of the description meta tag on wordpress head

Last update: 05.11.2024.

Use this code snippet to automate the filling of the description metatag under the wordpress engine. On the home page, the general settings page description will be taken from the code.

 

<meta name=”description” content=”<?php if ( is_front_page() || is_archive()||is_home() ) {?><?php bloginfo('description'); ?><?php } ?><?php if (have_posts() && is_single() OR is_page()):while(have_posts()):the_post();$out_excerpt = str_replace(array(“\r\n”, “\r”, “\n”), “”, get_the_excerpt());echo apply_filters('the_excerpt_rss', $out_excerpt);endwhile; endif; ?>” />

Copy to Clipboard

Related posts

Got a question? Is something not working? Write and I'll answer!

Leave a Reply

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