WordPress.org

Ready to get started?Download WordPress

Forums

Add a sub-title to posts when shown in categories (3 posts)

  1. The Painted Hive
    Member
    Posted 2 years ago #

    Hi all

    I'm sure there is a way to achieve this though I'm not sure where to start.
    I want to give my post titles a sub-title when someone clicks the category it is in.
    For example, say I have a post titled, "Cabinet Makeover" and it is categorised under "Before and After" and "Furniture Transformations". On my main blog pages, the title of the post would simply appear as "Cabinet Makeover", however, if someone was to click the "Before and After" category link (in my sidebar, post meta or pages menu), the title would then appear like this, "Before and After: Cabinet Makeover". And if someone was to click the "Furniture Transformations" category link, the post title would read, "Furniture Transformations: Cabinet Makeover". And so on.
    Basically I am just trying to achieve some consistency with the way my categorised posts are titled because I want to eventually create pages linked to each one. So if you were to click the "Before and After" page, it would return a list of post excerpts all with the title of "Before and After: (Actual Title Here)". It would just look nice, clear and organised.

    Does this make sense?

    Sorry, my site is only hosted locally for now so I can't provide a link.

    Any advice/ideas would be greatly appreciated.

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    in category.php:

    example (code taken from 'kubrick default'):
    change from:
    <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>

    to:
    <h3 id="post-<?php the_ID(); ?>"><?php single_cat_title(); ?>: <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>

  3. The Painted Hive
    Member
    Posted 2 years ago #

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic