Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1161641
    chrisjoseph
    Participant

    Hi,

    I’ve looked at responses to previous questions and am able to alter the meta appearing above a post by altering functions.php in a child theme.

    However the client is now requesting that only the date appears above the post, and the author name and category tags appear beneath the post.

    Can you advise on how to add the author name and category tags beneath each post? I’m using the Icon stack.

    thanks!

    #1161666
    chrisjoseph
    Participant

    Hello,

    I’ve worked out a way to do this, by

    1) putting a copy of _content-the-content.php in x-child/framework/views/global

    2) putting the following code between <?php the_content(); ?> and <?php x_link_pages(); ?>

     <?php 
       $author = sprintf( '<span>Author: <a href="%1$s">%2$s</a></span>',
          get_author_posts_url( get_the_author_meta( 'ID' ) ),
          get_the_author()      
        );
    	
    	$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>Tags: %s</span>',
            trim( $categories_output, $separator )
          );
       
       printf( '<p class="p-meta">%1$s %2$s</p>',
            $author,
            $categories_list
          ); ?>
    #1161676
    Thai
    Moderator

    Glad you’ve sorted it out.

    If you need anything else, please let us know 🙂

  • <script> jQuery(function($){ $("#no-reply-1161641 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>