• Resolved giglio

    (@giglio)


    I found on the net some interesting discussions about how add the meta tag description for categories ( the plugin i use for SEO do not permit to add it)
    So i try to apply what read on the discussione and i add to
    <head> section of header.php file of my theme the following code:
    <meta name="description" content="<?php if ( is_category() ) { echo category_description(); } ?>"/>
    but in this way even categories have their own meta description, the pages and posts meta description is lost.

    So who could help me in create a code that permit to add mata descrption to categories and left the existing descriptions of posts and pages

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • try to make the whole thing conditional;

    change from:

    <meta name="description" content="<?php if ( is_category() ) { echo category_description(); } ?>"/>

    to:

    <?php if ( is_category() ) { ?>
    <meta name="description" content="<?php  echo category_description(); ?> "/>
    <?php } ?>

    Thread Starter giglio

    (@giglio)

    Hi alchymith,
    as i’m adding your code i think that it was a great idea, and that the results:
    it works!

    The former code do not clear the meta description existing but added

    <meta name="description" content="">

    in case of poste and pages before the existing one so no description was added.

    Many thanks :-))

    you are welcome 😉

    if this is all working, please mark this thread as ‘resolved’

    Thread Starter giglio

    (@giglio)

    Sure i was waiting for an answer.

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘meta tag decription for categories & posts’ is closed to new replies.