Forums

Can category descriptions be shown to users? (11 posts)

  1. pezastic
    Member
    Posted 7 years ago #

    Three days and no response to another post, I'm going to pose this question again. Is there a reason that I have spent time entering the descriptions to almost 100 categories? I would like a way to display them to users, preferably on a mouseover. Is this possible?

  2. yearginsm
    Member
    Posted 7 years ago #

    I tried it as <?php echo category_description(); ?>, and it worked on pages where the blog file was filtered based on category (http://www.example.com/blog/index.php?c=2).

    Hope that helps.

  3. Kafkaesqui
    Moderator
    Posted 7 years ago #

    If you want your category links to provide the description in the link alt attribute (which I assume is what you're after), you'll have to edit the source for this. If you're up for *that*, the file is

    wp-includes/template-functions-category.php

    Look for the function list_cats, towards the end of that file. Then search out this section:

    if ($use_desc_for_title == 0 || empty($category->category_description)) {
    $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
    } else {
    $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description)) . '"';
    }

    Change it to this:

    if ($use_desc_for_title == 0 || empty($category->category_description)) {
    $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
    } else {
    $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description)) . '"';
    $link .= ' alt="' . wp_specialchars(apply_filters('category_description',$category->category_description)) . '"';
    }

  4. pezastic
    Member
    Posted 7 years ago #

    That was exactly what I needed. Thank you VERY much, both of you!

    (Why can't that core mod be a part of the default WP?)

    One thing I noticed... There's an unwanted space after apostrophes. For instance, if I made a category description of "My aunt's son" it displays as "My aunt' s son" with a space after the apostrophe. How do I avoid this?

  5. Kafkaesqui
    Moderator
    Posted 7 years ago #

    I'm not seeing that problem at all. Which version of WordPress do you use, and what solution above did you go with?

  6. pezastic
    Member
    Posted 7 years ago #

    Kafkaesqui,

    I went with your solution for the mouseover and I plan on implementing the other solution in a category listing in the near future. (I still think your mouseover solution should be a part of the WordPress default core.)

    Regarding the apostrophe space, I have noticed that it only occurs on Windows computers that are in Chinese. My Windows English-install PC doesn't have this problem.

  7. MisterTut
    Member
    Posted 7 years ago #

    I'm looking for something similar, a way to get the "short description" to appear on mouseover for links from the link manager (as opposed to Categories as discussed above).

    Any thoughts?

    I am using WP 1.2.2.

    Thanks,

    -Tut
    http://www.health-hack.com

  8. MisterTut
    Member
    Posted 7 years ago #

    Actually, to clarify, that happens automatically. What I need is for the short description to appear ONLY on mouseover.

    This is strangely already happening for some of my link categories, but not all.

  9. Kafkaesqui
    Moderator
    Posted 7 years ago #

    MrTut, if a link has a description under the Links Manager, it will display in the title attribute. Are you sure those links that do not have descriptions appearing on mouseover actually do have them? Also, do you know which template tag(s) is being used to list your links?

  10. MisterTut
    Member
    Posted 7 years ago #

    I removed descriptions (temporarily) from the problem link lists, as while they were showing on mouseover, they were also plainly visible right after the text of the link. That looked too sloppy.

    In terms of template tags, isn't that exclusive to wp 1.5? I'm using 1.2.2 and am unfamiliar with that terminology.

    The "Related Links" list works as desired, but when short descriptions are added to links in the lists "Friends of HHDC" or "Sites of Note" I get the description text in mouseover AND printed right next to the link name.

    This is on http://www.health-hack.com/index.php

    Thanks,

    -Tut

  11. MisterTut
    Member
    Posted 7 years ago #

    Heh, Um, (red faced)... I figured it out. nevermind. Sorry. It was just a setting under Links/Link Categories/Edit/Show: Description.

    Doh!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.