Category title and description

resolved (9 posts) (3 voices)

  1. wacka
    Member

    Hi! I'm new to Elegance theme and I would deeply appreciate help with one specific problem. I have always used the category pages a lot - all SEO work has pointed to them, with great results. Now I really need this:

    1. The category title as the H1 intro_title (not Archives)
    2. The category description as the intro teaser text

    I understand that this is not a feature you've got. No problems, I'm prepared to edit the theme.php file (at least, thats where I think it comes from).

    Any ideas how I need to change in the following?

    if ( is_archive() ) {
    $intro_options = mysite_get_setting( 'intro_options' );
    if( $intro_options != 'disable' ) {
    $title = __( 'Archives', MYSITE_TEXTDOMAIN );
    if( is_category() ) {
    $text = sprintf( __('Category Archive for: %1$s', MYSITE_TEXTDOMAIN ), '‘' . single_cat_title('',false) . '’');

    By the way: I think(?) a quick fix with the title would mess things up with other archives than the categories. But that's ok for me, I don't use either tag or chronological archives.

    Posted 5 years ago #
  2. wacka
    Member

    Partially - but only partially - solved. I found another thread and it gave me enough clues to do this:

    $title = single_cat_title('',false);
    if( is_category() ) {
    $text = category_description('',false);

    It works fine, but the intro/teaser styling disappears for the description. Example: http://www.wpr.se/amnen/webbstrategi/

    Looking at it, it seems as if Wordpress adds an extra <p> just before the description content. It can't be seen in the Category editor. This is not your fault, of course, but have you encounterad the problem before? Any ideas on how to solve it?

    Posted 5 years ago #
  3. Elliott
    Support

    Hello wacka,

    Are you sure that's all you changed? Right now your teaser field is empty and you have two additional paragraphs being inserted.

    I was trying to hide it via CSS but it's not working for some reason,

    #intro_inner > p:last-child {
        display: none !important;
    }
    Posted 5 years ago #
  4. wacka
    Member

    Nothing else is changed, and when I look at the output it seems to me as the only difference from a working teaser is the extra <p>.

    Did you suggest I use the code above somewhere? Thanks!

    Posted 5 years ago #
  5. Elliott
    Support

    What do you have your intro set to? Is it title & teaser? Try switching it around.

    Posted 5 years ago #
  6. wacka
    Member

    Tried switching around between the different options, doesn't make any difference.

    Actually, I'm pretty sure this problem isn't yours. More googling led me to http://wordpress.org/support/topic/get-rid-of-p-tags-in-category_description which indicates the extra <p> is a known issue with WP. The solution recommended is to add remove_filter('term_description','wpautop'); to the theme's functions.php.

    Any advice on this potential solution? Will it blow the theme to pieces...?

    Posted 5 years ago #
  7. Elliott
    Support

    You can try it. Add it around line 210 in /wp-content/themes/[your_theme]/framework.php.

    You can also try surrounding your category description with [raw] [/raw] tags.

    Posted 5 years ago #
  8. wacka
    Member

    I couldn't get the raw-tags to work for some reason but you gave me an idea so I decided to strip the string of all html, and that finally worked. The theme.php part dealing with categories now look like below, and the styling comes through as it should.

    if( is_category() ) {
    $text = category_description('',false);
    $text = strip_tags($text);

    Thanks a lot for your efforts, Elliot.

    Posted 5 years ago #
  9. vsimons
    Member

    It may be 11 months old, but this post by wacka just solved a huge problem I was having with getting the correct category description to appear - so thanks. :)

    Posted 4 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme