You are developing a WordPress theme with the Genesis framework and you want to customize the post info area. This article explains what is the post info area, how you can customize it and where you can find the reference information you need.
What is the post info and how Genesis displays it by default
The post info area is the area of a post where you display information like the publish date, the author, the categories and the tags of a post. In a WordPress Genesis theme these data are called post info.
In a previous post I explained how you can customize the position of the post info. In this post I want to explain how you can customize its content.
As of Genesis version 3.0 by default the post info displays the publish date and the author of the post. Genesis displays these data just below the post title. After them it displays the post content. Finally in the post footer it displays the categories and the tags (that are called post meta by Genesis).
Maybe you want to display the categories and tags below the title, like I did in this blog. Moreover, if your blog has just one author you don’t want to display the author.
Elements to customize the post info
The key elements to customize the post info are the genesis_post_info filter and the post shortcodes. By using these two together you can obtain the post info you like. For example if your post info area should contain the date and the categories, the code to use would be:
add_filter( 'genesis_post_info', 'mytheme_genesis_post_info' );
function mytheme_genesis_post_info(){
return '[post_date]. [post_categories before="Categories: " sep=" | "]';
}
In this example the categories are preceded by the word ‘Categories’ and the separator between them is ‘ | ‘ instead of the default comma.
As I explained in the article about the post meta position, you can write this code in the functions.php file or in a template file. It depends whether this setting should affect all pages that display posts or just one type. If you want to understand how WordPress templates work, you can find the explanation here.
Keep in mind that by default Genesis renders the post_categories shortcode in a div. This means that it is rendered as a block element, so in a new line. If you want to display the categories on the same line as the date you have to edit the css file and convert it to an inline element:
.entry-categories,
.entry-tags {
display: inline;
}
List of available shortcodes for post info
The one above was just an example. By using the shortcodes you can customize the post info according to your preferences. Where can you find the list of available shortcodes?
- In the Genesis documentation
- in the Genesis source code.
The file for post shortcodes is genesis/lib/shortcodes/post.php under the wp-content/themes folder. There the code comments below the add_shortcode function describe all parameters of every shortcode.
Removing the categories and tags from the footer of the post
With the code above you displayed the categories right below the post title. However, Genesis still displays the post categories and tags in the footer of the post. If you want to remove them, you have to remove the genesis_post_meta action from the post footer:
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
Conclusion
With the genesis_post_info filter and the post shortcodes you can create your own post info layout. You can find all available shortcodes in the Genesis documentation or in the source code.