Community Forums › Forums › Design Tips and Tricks › Display Category Above Post Title?
Tagged: .post-info, category, featured widget amplified, post meta, posts
This topic contains 9 replies, has 4 voices, and was last updated by Dorian Speed 5 months ago.
-
AuthorPosts
-
December 16, 2012 at 10:40 pm #5670
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 #5743Don’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() );
}
}-
This reply was modified 5 months ago by
kosmiq.
-
This reply was modified 5 months ago by
kosmiq.
December 17, 2012 at 9:39 am #5747The 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 #5755Hi 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 #5802I’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 );
Web designer and avoider of chores.
Bringing websites Up to Speed! Follow me on Twitter!-
This reply was modified 5 months ago by
Dorian Speed.
-
This reply was modified 5 months ago by
Dorian Speed.
December 18, 2012 at 11:40 am #5952Didn’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 #6064You 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 #6073You 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 );
Web designer and avoider of chores.
Bringing websites Up to Speed! Follow me on Twitter!December 18, 2012 at 9:09 pm #6075Sorry, doesn’t work. Is the only way to get what I’d like the genesis loop?
December 18, 2012 at 10:30 pm #6096This 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?
Web designer and avoider of chores.
Bringing websites Up to Speed! Follow me on Twitter! -
This reply was modified 5 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.