Forums

How to print category name in title tag? (5 posts)

  1. balkanguy
    Member
    Posted 3 years ago #

    I have this:

    echo single_cat_title(''); wp_title(''); echo ' - some more keywords';

    Category name is not showing in title tag, everything else does.
    How should this line look like?

    Thanks

  2. balkanguy
    Member
    Posted 3 years ago #

    This code displays category name outside of the loop, but don't know how to make it work inside title tag

    <?php
    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' ';
    }
    ?>
  3. balkanguy
    Member
    Posted 3 years ago #

    Anyone?

  4. gmisen
    Member
    Posted 3 years ago #

    did you ever figure this out? i'm having the same problem

  5. Zoinks! Graphics
    Member
    Posted 2 years ago #

    Give this a shot....

    <title><?
    
    if(is_front_page())
    	{ echo get_bloginfo('name') . ' &raquo; ' . get_bloginfo('description'); }
    else	{
    	wp_title('&laquo;',true,'right');
    
    	if(is_single())
    		{
    		$category = get_the_category();
    		echo $category[0]->cat_name . ' &laquo;';
    		}
    
    	echo ' ' .  get_bloginfo('name');
    	}
    
    ?></title>

Topic Closed

This topic has been closed to new replies.

About this Topic