How to add author to Blog entries in Icon stack

Hi,

I am building a new site with the Icon stack. We’d like for the author name to be listed as well as the date. I’ve added the following css code that adds a slash before the date:

   .single-post .p-meta span:first-of-type:before,
   .blog .p-meta span:first-of-type:before {
                content: "/ ";
    }

Is there a way I can add the author name before the slash?

Thanks,
Alison

Hi Alison,

Thank you for writing in, while that is outside the scope of support, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

First of since this requires a customization, you need to setup and activate a child theme

How To Setup Child Themes

Then add this following function to your child theme’s functions.php file

Customization Best Practices

if ( ! function_exists( 'x_icon_entry_meta' ) ) :
  function x_icon_entry_meta() {

    //
    // Author.
    //

    $author = sprintf( '<span>by: %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() )
    );


    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s/%2$s</p>',
         $author,
        $date
      );
    }

  }
endif;

You might need to remove your custom CSS since there is already an / on the output between author and date.

Happy New Year,
Cheers!

Hi,

Thanks for the specifics on doing this with a child theme. I was hoping it would be possible to add the author via CSS code. Another option I noticed was to use the author shortcode in the body of the post. Please let me know of any suggestions for adding the author that I could do without making changes to the functions.php file.

Thanks,
Alison

Hi Alison,

That’s NOT possible because it would require a template change.

We need to put all the custom code under functions.php file and it would be safe for the future updates.

Regards!

Hi,

Thanks for the explanation. Appreciate your quick response.

All best,
Alison

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.