• Resolved grishart

    (@grishart)


    Hi all
    Is it possible to have the category slug in the postmetadata rather then the category name?
    Posted by <?php the_author() ?> in <?php the_category(', ') ?> on

    Also how do I get the Category Description in to the header meta of the the page?
    <meta name="description" content="xxxx xx xxx xx x x xxxx x">

    Thanks for your time

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    For your first problem try it with this instead of the_category(', ')

    <?php
     $categories = get_the_category();
     if($categories) : 
    
     $html = '';
     foreach ( $categories as $cat  ) {
     $html .= '<a href="'.get_category_link( $cat->term_id ).'">'.$cat->slug.'</a>, ';
     }
     ?>
    <p>Posted by <?php the_author() ?> in <?php echo trim($html, ', '); ?></p>
    <?php endif; ?>

    Also how do I get the Category Description in to the header meta of the the page?

    Do you want this on every page or only on category archive pages?

    Thread Starter grishart

    (@grishart)

    Hi Thanks
    I will try that straight away and no I just want it on the category index pages.

    Thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    For your second question try it with this inside your <head></head> tags (header.php):

    <?php if(is_category()) :
    $thisCat = get_category(get_query_var('cat'));
    if($thisCat->description) :
    ?>
    <meta name="description" content="<?php echo $thisCat->description; ?>">
    <?php endif; ?>
    <?php endif; ?>

    Thread Starter grishart

    (@grishart)

    Hi keesiemeijer

    Have just tried that and it works perfectly.

    many thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    No problem. Glad you got it resolved

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘category slug’ is closed to new replies.