• Resolved insurgenesis

    (@insurgenesis)


    How do I add category headings / titles to single posts?

    The problem is really that single posts are removed from the category sequence and so you can’t cycle through to adjacent posts within the same category unless the navigation is customised like this:
    <?php previous_post_link('%link', 'Previous in category', TRUE); ?>
    BUT it’s very confusing if someone stumbles upon a single post where the category to which it belongs is omitted.

    All I know is that I can’t simply get category headings in single posts by using the code found in category.php :
    https://pastebin.com/4uYYc7wA

    I don’t know why this is the case.
    Perhaps there is a more economical way.
    Anyone felt the same about this?

Viewing 8 replies - 16 through 23 (of 23 total)
  • i’m busy trying to solve the issue from my last post…

    you’ve got me intrigued here so if i get impatient it would only be a good thing as it would confirm your suspicion that single.php is really not playing nice…

    or i’m just not clever enough to figure it out

    Thread Starter insurgenesis

    (@insurgenesis)

    no hahaha i’m truly lost

    You think you’re lost? No, we’ve almost reached the 20-post threshold – stoksielalleen op ‘n Saterdag aand.

    Yes that result is to be expected but when you tested it, as you said you did, did the category title/heading show?

    As I said, I can see mine in firebug only partly there…

    BTW do you earn a living with WP?

    I finaly got the category to show in single.php but the below code needs to be pasted below the loop start:

    <header class="page-header">
            <h1 class="page-title"><?php the_terms( $post->ID, 'Skills', 'Category Archives: <span>', '</span>, <span>', '</span> ' ); ?></h1>
        </header>

    remember to change skills to your own custom taxonomy

    Thread Starter insurgenesis

    (@insurgenesis)

    Where precisely should I paste it in the code I put in the pastebin link? I’m it goes in single.php?
    I don’t know what to replace “Skills” with because I don’t use custom taxonomies. Can I just leave it blank like ” ?

    Nope see below code tested works fine now with normal categories:

    <header class="page-header">
            <h1 class="page-title">Category Archive: <?php
                $seperator  = ' &bull; ';
                $parents    = '';
                $post_id    = $post->ID;
    
                the_category( $seperator , $parents, $post_id );
                ?>
            </h1>
        </header>

    Paste this code just below the following line in single.php:

    <?php while ( have_posts() ) : the_post(); ?>

    Thread Starter insurgenesis

    (@insurgenesis)

    Hi tiaanswart, thanks for looking into it.
    I can confirm that categories now show up above single posts.
    However, they looked completely wrong and my custom css had to be mangled to work it so that I could style with these selectors:
    .page-title {} .page-title a {}.

    It’s good to know forums can intrigue us isn’t it.
    Thanks again.

    Thread Starter insurgenesis

    (@insurgenesis)

    Do you have the means to receive a PM?

    These forums does not provide support via personal messaging.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Twenty Eleven Adding category title in single posts’ is closed to new replies.