This document is deprecated! The information on this page refers to a Thesis version that is now obsolete. Please visit the Thesis Docs for current documentation.
The code in this article is compatible only with version 1.7 or higher of Thesis.
Display Author, Date, and Category ∞
This custom code will give your teasers a byline in this format:
by (author) on (date) in (category)
First, uncheck the author name, date, and primary category elements under Design Options > Teasers > Teaser Display Options to avoid duplication.
Then, place this code in custom_functions.php
:
function my_teaser_byline() { global $thesis_design; $date_formats = thesis_get_date_formats(); $use_format = ($thesis_design->teasers['date']['format'] == 'custom') ? $thesis_design->teasers['date']['custom'] : $date_formats[$thesis_design->teasers['date']['format']]; echo '<span class="teaser_author">'; thesis_author(); echo '</span>'; echo "\n"; echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">on ' . get_the_time($use_format) . '</abbr>' . "\n"; $categories = get_the_category(); echo '<a class="teaser_category" href="' . get_category_link($categories[0]->cat_ID) . '">in ' . $categories[0]->cat_name . '</a>' . "\n"; } add_action('thesis_hook_after_teaser_headline', 'my_teaser_byline');
Display Date, Edit Link, and Category (on Separate Lines) ∞
This version pulls together the date, edit link, and category, then adds paragraph tags to the category function to put it on a line by itself.
First, uncheck the date, edit post link, and primary category elements under Design Options > Teasers > Teaser Display Options to avoid duplication.
Then, place this code in custom_functions.php
:
function my_teaser_byline() { global $thesis_design; $date_formats = thesis_get_date_formats(); $use_format = ($thesis_design->teasers['date']['format'] == 'custom') ? $thesis_design->teasers['date']['custom'] : $date_formats[$thesis_design->teasers['date']['format']]; echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . '</abbr>' . "\n"; edit_post_link(__('edit', 'thesis'), '<span class="edit_post">[', ']</span>'); echo "\n"; $categories = get_the_category(); echo '<p><a class="teaser_category" href="' . get_category_link($categories[0]->cat_ID) . '">' . $categories[0]->cat_name . '</a></p>' . "\n"; } add_action('thesis_hook_after_teaser_headline', 'my_teaser_byline');