Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #667838

    demonboy
    Participant

    I’m using Renew and I’d like to include the publish date under the title. I am assuming I add the following:

    <?php the_date('Y-m-d', '<h2>', '</h2>'); ?>

    in the file _landmark-header.php within the renew folder, correct?

    I’ve tried add this line in at around line 51:

              <?php elseif ( is_home() || is_single() ) : ?>
                <?php if ( x_is_portfolio_item() ) : ?>
    
                  <h1 class="h-landmark"><span><?php echo x_get_parent_portfolio_title(); ?></span></h1>
    
                <?php else : ?>
    
                  <h1 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h1>	
                 <?php the_date('Y-m-d', '<h2>', '</h2>'); ?>
    
                <?php endif; ?>

    But this didn’t display the date. Could you tell me what I am doing wrong, please? Example blog post here: http://followtheboat.com/esper-rammed-and-an-american-comes-to-the-rescue/

    #667939

    Paul R
    Moderator

    Hi,

    Thanks for writing in!

    The date is already included, you can enable post meta under Blog > Content > Post meta in the customizer(Appearance > Customize).

    Hope that helps.

    #667972

    demonboy
    Participant

    Hi,

    I’m afraid this does nothing. I just want to add a publish date line under the heading. Which file do I need to change in my child theme?

    Thanks

    #667984

    Christopher
    Moderator

    Hi there,

    Renew by default display meta information, please check this link: http://theme.co/x/demo/renew/1/5-reasons-you-need-the-x-theme/

    Did you enable ‘Post meta’ in customizer and still it doesn’t work? please activate parent theme and let us know if it solves the issue.

    Thanks.

    #668071

    demonboy
    Participant

    I don’t want all the meta info, I only want the date. That is is! I just need to know which file to add it to, please.

    #668080

    Paul R
    Moderator

    Hi,

    To show just the date, please enable post meta and add this in your child theme’s functions.php file.

    
    function x_renew_entry_meta() {
    
        //
        // Author.
        //
    
        $author = sprintf( '<span>%s</span>',
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() )
        );
    
        //
        // Categories.
        //
    
        if ( get_post_type() == 'x-portfolio' ) {
          if ( has_term( '', 'portfolio-category', NULL ) ) {
            $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
            $separator         = ', ';
            $categories_output = '';
            foreach ( $categories as $category ) {
              $categories_output .= '<a href="'
                                  . get_term_link( $category->slug, 'portfolio-category' )
                                  . '" title="'
                                  . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                  . '"> '
                                  . $category->name
                                  . '</a>'
                                  . $separator;
            }
    
            $categories_list = sprintf( '<span>%s</span>',
              trim( $categories_output, $separator )
            );
          } else {
            $categories_list = '';
          }
        } else {
          $categories        = get_the_category();
          $separator         = ', ';
          $categories_output = '';
          foreach ( $categories as $category ) {
            $categories_output .= '<a href="'
                                . get_category_link( $category->term_id )
                                . '" title="'
                                . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                . '">'
                                . $category->name
                                . '</a>'
                                . $separator;
          }
    
          $categories_list = sprintf( '<span>%s</span>',
            trim( $categories_output, $separator )
          );
        }
    
        //
        // Comments link.
        //
    
        if ( comments_open() ) {
    
          $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
          $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
          $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
    
          if ( $number == 0 ) {
            $text = __( 'Leave a Comment' , '__x__' );
          } else if ( $number == 1 ) {
            $text = $number . ' ' . __( 'Comment' , '__x__' );
          } else {
            $text = $number . ' ' . __( 'Comments' , '__x__' );
          }
    
          $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
            esc_url( $link ),
            esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
            $text
          );
    
        } else {
    
          $comments = '';
    
        }
    
        //
        // Output.
        //
    
        if ( x_does_not_need_entry_meta() ) {
          return;
        } else {
          printf( '<p class="p-meta">%s</p>',       
            $date   
          );
        }
    
      }
    

    Hope that helps.

    #669317

    demonboy
    Participant

    OK, but which file controls the format of a single post? Is it _landmark-header.php?

    #669320

    demonboy
    Participant

    By the way, I have added the code above to my functions file in my child theme. I have turned on the post meta in my customisation but I am still not seeing the date.

    All I want to do is add the date under the title. Surely it is just a hook within the WordPress loop, no? I don’t want to be bothered about turning meta data on or off, I just want to customise whatever file it is that controls the layout for a single blog post by inserting the correct hook.

    #669444

    Rupok
    Member

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #669900

    demonboy
    Participant
    This reply has been marked as private.
    #669923

    Zeshan
    Member

    Hi there,

    Please also provide us with your FTP login credentials so we can take a look at your backend files. Don’t forget to select Set as private reply to ensure your data remains hidden from other users.

    Thank you!

    #682606

    demonboy
    Participant
    This reply has been marked as private.
    #682613

    Rue Nel
    Moderator

    Hello There,

    Upon checking your site, the date is displaying underneath your post titles.
    http://prntscr.com/986zqs
    http://prntscr.com/98700o

    To control which file is displaying in the single post title and the date without having to turn on the post meta in the customizer, please follow this steps:
    1] Please create a new file in your local machine.
    2] Insert the following code into the file:

    <?php
    
    // =============================================================================
    // VIEWS/RENEW/_CONTENT-POST-HEADER.PHP
    // -----------------------------------------------------------------------------
    // Standard <header> output for various posts.
    // =============================================================================
    
    ?>
    
    <header class="entry-header">
      <?php if ( is_single() ) : ?>
      <h1 class="entry-title"><?php the_title(); ?></h1>
      <?php the_date('Y-m-d', '<p class="p-meta">', '</p>'); ?>
      <?php else : ?>
      <h2 class="entry-title">
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_title(); ?></a>
      </h2>
      <?php endif; ?>
      <?php x_renew_entry_meta(); ?>
    </header>

    3] Save this file named as _content-post-header.php and upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/renew/

    Please make sure that you have turn off the post meta because it will display duplicate dates. Please let us know if this works out for you. Thank you.