• Home
  • Pricing
  • Showcase
  • Login
DIYthemes
Click here and like us on Facebook

Thesis Theme User’s Guide

Documentation, How-tos, and Best Practices for the Thesis WordPress Theme

  • Table of Contents
  • Hooks
  • Filters
  • Thesis Blog →
Share

Customize the Post Byline

Thesis offers several options for controlling the information which displays in your byline. To view and/or change these options, navigate to Design Options, then look under Display Options : Bylines.

In some cases, you may need to use custom functions to achieve the results you want. Here are some examples of how to make changes to the byline, using both the standard options and custom functions.

Hide Number of Comments ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show number of comments in byline” option.

Hide Post Categories ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show post categories” option.

Move Post Categories to First Line ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show post categories” option. Then, place this code in custom_functions.php:

function add_to_byline() {
  if (!is_page())
    echo ' in <span>' . get_the_category_list(',') . '</span>';
}

add_action('thesis_hook_byline_item', 'add_to_byline', '99');

Move Entire Byline to After Post ∞

In the Design Options panel, under Display Options : Bylines, uncheck all options. Then, place this code in custom_functions.php:

function custom_byline() { ?>

<p class="headline_meta"><?php thesis_author(); ?> on <abbr class="published" title="<?php echo get_the_time('Y-m-d'); ?>"><?php echo get_the_time(get_option('date_format')); ?></abbr>
 &middot; <span><a href="<?php the_permalink(); ?>#comments" rel="nofollow">
 <?php comments_number(__('0 comments', 'thesis'), __('1 comment', 'thesis'), __('% comments', 'thesis')); ?></a></span></p>

<p class="headline_meta"><?php the_tags('tagged as <span>', ', ', '</span>'); ?>
 in <span><?php echo get_the_category_list(','); ?></span></p>

<?php }

add_action('thesis_hook_after_post', 'custom_byline');

Add “Posted In” Before Category ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show post categories” option. Then, place this code in custom_functions.php:

function add_to_byline() { ?>
    </p><p class="headline_meta"><?php echo __('Posted in:', 'thesis') . ' <span>' . get_the_category_list(',') . '</span>'; ?>
<?php }
add_action('thesis_hook_byline_item', 'add_to_byline', '99');

Add Time Stamp After Published On Date ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show published-on date in post byline” and “Show number of comments in byline” options. Then, place this code in custom_functions.php:

function custom_byline() {
  if (!is_page()) { ?>
  <p class="headline_meta"><abbr class="published" title="<?php echo get_the_time('Y-m-d H:i'); ?>"><?php echo get_the_time(get_option('date_format')); ?> <?php the_time('G:i a'); ?></abbr>
 &middot; <span><a href="<?php the_permalink(); ?>#comments" rel="nofollow">
 <?php comments_number(__('0 comments', 'thesis'), __('1 comment', 'thesis'), __('% comments', 'thesis')); ?></a></span></p>
<?php }
}

add_action('thesis_hook_after_headline', 'custom_byline');

Note: This code excludes Pages from having the custom byline applied; you will need to remove the extra conditional code if you wish to use it on Pages as well.

Move Date to Before Title ∞

In the Design Options panel, under Display Options : Bylines, uncheck the “Show published-on date in post byline” and “Show published-on date in page byline” options. Then, place this code in custom_functions.php:

function add_to_byline() { ?>
   <p class="headline_meta"><?php echo (''). ' <span>' .get_the_time('F j, Y') . '</span></p>'; ?>
<?php }

add_action('thesis_hook_before_headline', 'add_to_byline', '1');

Display an Avatar Next to Byline ∞

Place this code in custom_functions.php (replacing http://www.example.com/path/to/your/images/avatar.gif with the URL to your avatar):

/* byline avatar */
function byline_avatar() {
echo '<img class="byline_avatar" src="http://www.example.com/path/to/your/images/avatar.gif" />';
}

add_action('thesis_hook_before_headline', 'byline_avatar');

Then, place this code in custom.css (adjust margin value as desired):

/*avatar styles*/
.custom .byline_avatar {
   float: left;
   margin-right: 0.5em;
   margin-bottom: 0.5em;
}

Avatars for Multiple Authors ∞

Place this code in custom_functions.php (replace 50 with the desired pixel size):

/* byline avatars */
function byline_avatars() {
  echo get_avatar(get_the_author_id(), 50);
}

add_action('thesis_hook_before_headline', 'byline_avatars');

Then, place this code in custom.css (adjust margin value as desired):

/*avatar styles*/
.custom .avatar {
   float: left;
   margin-right: 0.5em;
   margin-bottom: 0.5em;
}

Hide Byline on Archives & Category Pages Only ∞

Place this code in custom_functions.php:

function custom_body_class($classes) {
 if (is_archive() || is_category()) {
    $classes[] .= 'hide_meta';
 }
    return $classes;
}
add_filter('thesis_body_classes', 'custom_body_class');

Then, place this code in custom.css:

/* hide meta */
.custom.hide-meta .headline_meta {display:none;}

Related Resources:

  • thesis_hook_byline_item
  • WordPress conditional tags
  • Date formats reference – PHP Manual

Get Email Updates (it’s Free)

Interested in Thesis?

Thesis is more than just a WordPress theme—it’s a community of wonderful people who are dedicated to building better websites. Try Thesis today at no risk and learn from the Thesis pros in our members-only forums!

Try Thesis now »

  • Search

  • Recently Added

    • How to Add Pinterest to WordPress
    • Customize the Password Form on Protected Posts
    • Using Thesis SEO Options and Settings
    • How to Add Frames to Individual Images in WordPress
    • How to Remove Hello Bar on Some WordPress Pages
  • Most Popular How-tos

    • Create and Customize an Archives Page
    • Using Post Image and Thumbnail Options
    • Default Post Image and Thumbnail Settings
    • Delete Thesis Database Options
    • Aspect Ratios for Image Rotator
    • Using the No Sidebars Template for Pages
    • Include Additional Pages in Nav Menu
    • Configure Static Front and Posts Pages
    • Using Custom CSS Classes for Posts and Pages
    • Hide “Comments on this entry are closed” Message
    • Configure Features and Teasers
    • Include Custom Links in Nav Menu
    • Move Previous and Next Links
    • Add Separate Nav Menu for Categories
    • Move or Replace Nav Menu
    • Insert Ad After Content

© 2012 DIYthemes, LLC.

Want to earn cash promoting the best website framework on the planet? Sign up for our affiliate program today.

Log into DIYthemes