• Resolved 1200ug

    (@1200ug)


    How can I display the posts categories alongside the date it was posted on the single post?

    I have tried to copy the code that displays it on the excerpt but it doesnt work in the single.php file. The code that does it on the content.php file is `<span class=”cat-links”>
    <?php printf( __( ‘<span class=”%1$s”>Posted in</span> %2$s’, ‘twentyeleven’ ), ‘entry-utility-prep entry-utility-prep-cat-links’, $categories_list );
    $show_sep = true; ?>
    </span>`

    Can somebody please help me to display the posts categories next to the date it was posted please?

    Thanks ??

Viewing 1 replies (of 1 total)
  • Thread Starter 1200ug

    (@1200ug)

    I’ve sorted it, I just had to re-arrange content-single.php to the following:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header">
    		<?php the_post_thumbnail(); ?>
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    
    		<?php if ( 'post' == get_post_type() ) : ?>
    		<div class="entry-meta">
    			<?php
    				/* translators: used between list items, there is a space after the comma */
    				$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
    
    				/* translators: used between list items, there is a space after the comma */
    				$tag_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
    				if ( '' != $tag_list ) {
    					$utility_text = __( 'This entry was posted in %1$s and tagged %2$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
    				} elseif ( '' != $categories_list ) {
    					$utility_text = __( 'This entry was posted in %1$s by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
    				} else {
    					$utility_text = __( 'This entry was posted by <a href="%6$s">%5$s</a>. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyeleven' );
    				}
    
    				printf(
    					$utility_text,
    					$categories_list,
    					$tag_list,
    					esc_url( get_permalink() ),
    					the_title_attribute( 'echo=0' ),
    					get_the_author(),
    					esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )
    				);
    			?>
    		</div><!-- .entry-meta -->
    		<?php endif; ?>
    	</header><!-- .entry-header -->
    
    rest of content-single.php does here
Viewing 1 replies (of 1 total)
  • The topic ‘[Theme: Twenty Eleven] Display category underneath title’ is closed to new replies.