Author and Date just under the title

Home Forums General Support Author and Date just under the title

This topic contains 5 replies, has 2 voices, and was last updated by  Zeaks 2 days, 16 hours ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12826 Reply

    Alessio

    Hi guys!
    Thank you for your guide to put the excerpt in the theme Twenty Twelve.
    I did the child theme, but then I’m not good to manage php code…
    I would like to show my entry-meta under the title, instad at the bottom of the post.

    I don’t know what to move and what to change. At the moment in the child theme folder I have the files:
    – content.php
    – functions.php
    – style.css

    How can I change the post so I can see:
    TITLE
    entry-meta (Posted by “AUTHOR” on “DATE”)
    CORP OF THE POST

    at the moment is
    TITLE
    CORP OF THE POST
    entry-meta

    don’t know if it is usefull, here my single.php

    <?php
    /**
     * The Template for displaying all single posts
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php get_template_part( 'content', get_post_format() ); ?>
    
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thank you!

    ps. if you want to get an idea check out the site letskillthenoise.com

    #12828 Reply

    Zeaks
    Keymaster

    Hi Alessio. Moving the meta information for single post view is a bit more complicated. The single.php file calls the content template file

    <?php get_template_part( 'content', get_post_format() ); ?>

    so we need to look in there.
    Unfortunately the post layouts all work the same way as far as the header and footer of the post goes. The content file has sections for single, search, index etc, then displays the header and footer of the post along with it.

    Anyways, what needs to be done is in single.php the bit of code I posted above should be removed, and the header, content and footer section added directly to single.php. It’s a bit complicated so I went ahead and did this for you. Each section is commented, backup your current single.php and replace it with this one.

    <?php
    /**
     * The Template for displaying all single posts
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    			
    	<!-- Add the post header section -->		
    		<header class="entry-header">
    
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    	<!-- Add the meta data from the post footer-->
    			<div class="single-meta"><?php twentytwelve_entry_meta(); ?></div>
    
    		</header><!-- .entry-header -->			
    			
    	<!-- Add the content section for single posts -->	
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->			
    	
    	<!-- Keep the post navigation -->
    	
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    You might also want to add this to style.css to add some spacing between the meta info and post title.

    .single-meta { padding-top:10px; }

    Hope this helps!

    #12835 Reply

    Alessio

    So I tried to put your code but there was some errors.
    I used Meld to compare the old single.php file and the new.
    Found out some errors on the new you posted, lots of the were < ?php instead of <?php.
    a couple of </span> missing.
    after this the code is working good!
    Just a couple of things more:
    now I have the meta data displying double the author name ex:
    Posted by Alessio on 7 January 2015 by Alessio.

    I would like to get rid of the last author name.

    Second, now I’m working on the single.php of the parents theme, it means that once I do an update I will lose this changes.
    How can I do a new single.php in the child theme? is it enough to add a single.php file in the child theme folder?

    here the working single.php file with the changes.
    thank you!

    <?php
    /**
     * The Template for displaying all single posts
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    			
    	<!-- Add the post header section -->		
    		<header class="entry-header">
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    
    	<!-- Add the meta data from the post footer-->
    			<div class="single-meta"><?php twentytwelve_entry_meta(); ?></div>
    
    		</header><!-- .entry-header -->			
    			
    	<!-- Add the content section for single posts -->	
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">→', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->			
    	
    	<!-- Keep the post navigation -->
    	
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    #12836 Reply

    Alessio

    ah, just try to add the

    .single-meta { padding-top:10px; }

    to my style.css file, but it is not working :(

    #12837 Reply

    Alessio

    sorry, last message was my fault, spacing is working ;)
    had an editing error :)

    #12838 Reply

    Zeaks
    Keymaster

    Hi Alessio. you can drop that single.php file into your child theme directory and it will override the parent single.php.

    I tested it in my own child theme and didn’t receive any errors, could you post the error messages please and I’ll take another look.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Author and Date just under the title
Your information: