WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Title and description for specific category

[Resolved] Title and description for specific category

  • I would like to specify custom titles and descriptions for post categories (I’m redirecting certain pages to category pages that lists posts in that category). Is this possible? Right now, I only see a global option to include category name along with site title, but I can to customize contents of meta title and description a bit more. Thanks for the time.

    http://wordpress.org/extend/plugins/all-in-one-seo-pack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Peter Baylies

    @pbaylies

    There currently isn’t support for this in the plugin, although you should be able to add it using PHP by filtering aioseop_title and aioseop_description; we are planning on adding better support for this integrated into All In One SEO Pack. Below is a basic example of how you’d go about adding a filter here.

    add_filter('aioseop_title', 'sfwd_custom_title');
    
    function sfwd_custom_title($title) {
       if ( is_category() ) {
            $title = "Custom Category Title";
       }
       return $title;
    }

    So if I wanted to assign category title to categories with specific names, I would do something like this?

    add_filter('aioseop_title', 'sfwd_custom_title');
    
    function sfwd_custom_title($title) {
       if ( is_category() == "CategoryName" ) {
            $title = "Custom Category Title";
       }
       if ( is_category() == "CategoryName2" ) {
            $title = "Custom Category Title";
       }
       return $title;
    }
    
    add_filter('aioseop_description', 'sfwd_custom_desc');
    
    function sfwd_custom_desc($title) {
       if ( is_category() == "CategoryName" ) {
            $description = "Custom Category Description";
       }
       if ( is_category() == "CategoryName2" ) {
            $description = "Custom Category Description";
       }
       return $description;
    }
    Plugin Contributor Peter Baylies

    @pbaylies

    That’s close; but actually that should be is_category( “CategoryName” ) – check the Codex page for is_category() here.

    add_filter('aioseop_title', 'sfwd_custom_title');
    
    function sfwd_custom_title($title) {
       if ( is_category( "CategoryName" ) ) {
            $title = "Custom Category Title";
       } elseif ( is_category( "CategoryName2" ) ) {
            $title = "Custom Category Title 2";
       }
       return $title;
    }

    Brilliant. That worked perfectly. Thanks for the help Peter.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Title and description for specific category’ is closed to new replies.