Community Forums › Forums › Archived Forums › Design Tips and Tricks › Display Category Above Post Title?
Tagged: .post-info, category, featured widget amplified, post meta, posts
- This topic has 9 replies, 4 voices, and was last updated 11 years, 11 months ago by Dorian Speed.
-
AuthorPosts
-
December 16, 2012 at 10:40 pm #5670ithacaindyMember
I'd like to display the category (single) of each post above the title of the post. Is there a Genesis hook for this?
December 17, 2012 at 9:21 am #5743kosmiqMemberDon't think there is a genesis hook to do it all at once. However you should be able to do something like this:
/** Add category before title */
add_action( 'genesis_before_post_title', 'do_category_before_title' );
function do_category_before_title() {
printf( the_category() );
}You will probably need to add some styling etc. when it's visible, but it should at least display it.
If you only want it to appear when viewing a single post simply change it to
/** Add category before title */
add_action( 'genesis_before_post_title', 'do_category_before_title' );
function do_category_before_title() {
if( is_single() ) {
printf( the_category() );
}
}December 17, 2012 at 9:39 am #5747ithacaindyMemberThe function does fine inside the loop (i.e. on the full post) but does not appear outside the loop. I'm using the Genesis Featured Widget Amplified to handle posts outside the loop, in a custom sidebar.
December 17, 2012 at 10:36 am #5755ramseypMemberHi there,
If you're trying to add this to the output of the widget, you'll have to customize the widget itself so it knows what to do.
December 17, 2012 at 2:07 pm #5802Dorian SpeedMemberI'm probably missing something here, but can't you do that by showing either the Post Info or the Post Meta and customizing the output with shortcodes? [post_categories] to show the categories?
Oh, wait - you're asking how to show it above the title instead of after the title? Nick posted something to the codex about that. You could try his suggestion - add this to your functions.php:
remove_action( 'gfwa_before_post_content', 'gfwa_do_byline', 10, 1 );
add_action( 'gfwa_before_post_content', 'gfwa_do_byline', 8, 1 );
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet!December 18, 2012 at 11:40 am #5952ithacaindyMemberDidn't work. The post meta does appear at the bottom of posts displayed using Nick's plugin, however. How do I move the post meta above the post titles' headlines via GFWA?
December 18, 2012 at 8:00 pm #6064ramseypMemberYou would have to edit the widget's code. If you're not familiar with PHP at that level, it may require you finding a developer to work on that code for you or to use the support forums on wordpress.org for the plugin.
December 18, 2012 at 8:59 pm #6073Dorian SpeedMemberYou could try this:
remove_action( 'gfwa_after_post_content', 'gfwa_do_post_meta', 10, 1 );
add_action( 'gfwa_before_post_title', 'gfwa_do_post_meta', 1, 1 );
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet!December 18, 2012 at 9:09 pm #6075ithacaindyMemberSorry, doesn't work. Is the only way to get what I'd like the genesis loop?
December 18, 2012 at 10:30 pm #6096Dorian SpeedMemberThis worked for me just now on another site:
remove_action( 'gfwa_after_post_content', 'gfwa_do_post_meta', 10, 1 );
add_action( 'gfwa_before_post_content', 'gfwa_do_post_meta', 1, 1 );(The only change from what I pasted earlier was that I said "before_post_content" instead of "before_post_title".)
If that doesn't work, it might be a conflict with another plugin, maybe?
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet! -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.