How to change meta description ONLY if the page slug is this?
-
Hi there
With this code in functions.php, I am able to change the meta description if the current page slug is “some-slug”. Which is good.
However, as of now for ALL other pages, the meta-description tag has disappeared totally. What code should I use in ELSE section to retain the original meta-description for all other pages?function add_meta_description() { global $wp; $current_slug = add_query_arg( array(), $wp->request ); if ($current_slug = "some-slug") { $description = "custom description"; echo '<meta name="description" content="' . $description . '" />' . "\n"; } else { //Code needed to preserve default description //Do not change the description and do NOT make it blank } } add_action( 'wp_head', 'add_meta_description');
Thank you.
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘How to change meta description ONLY if the page slug is this?’ is closed to new replies.