I use custom category templates for a few of my categories. Ex: cat-12.php and so on. I use the Fv Simpler Seo and presently it doesnt seem to support an option to edit category templates.

Considering that I use custom category templates, is there a function or a way I include custom meta description and custom title (over riding the default category name that is picked up as the title) without having to use a plugin?


for meta description of the category you can use followinf dunction

function seometadescription(){
        global $post, $posts;
    if ( is_single() || is_page() ) : 
        $customDesc = 'meta_desc';
        if ( have_posts() ) : while ( have_posts() ) : the_post(); 
                $descriere = get_post_meta($post->ID, $customDesc, true);

    elseif( is_category() ):
        $descriere = category_description();
    elseif( is_front_page() ) : 
        $descriere = 'some words for front page description';
    $customMetaDesc = '<meta name="description" content="'.$descriere.'" />';
        echo $customMetaDesc;
// end meta desc function

$customDesc = is a custom field that I used for post and pages description If you have not ser a page as front page replace is_front_page() with is_home

For META keywords I found a function on this web site

| improve this answer | |

Agreed, most category template files do start with get_header and then you can add between the content="", but make sure you don't conflict with any PHP scripts.

<meta name="keywords" content="" />
<meta name="title" content="" />
<meta name="" />
| improve this answer | |

Take a closer look at custom category templates. There must be an option to edit them. May be not through dashboard, may be right in theme or plugin folder. I think it's impossible that there is no option to edit templates.

| improve this answer | |
  • Your answer is quite vague. The category template starts with the get header... – Sledge81 Jul 29 '11 at 18:18
  • You have distinct file which respond for displaying content of this category. Right? In this case you can replace get_header() with content of header.php and edit title and description. – Alexey Jul 29 '11 at 20:21
  • 1
    I don't think that is a good practice to put the header contents directly into the category template files. – Sledge81 Jul 30 '11 at 6:16
  • 1
    agree, it's not a good practice, but it works :). Another solution - you may use conditional tag is_category() link – Alexey Jul 30 '11 at 16:12
  • Probably.. will have to give that a try, if there is indeed no other method – Sledge81 Jul 30 '11 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.