Display Category Above Post Title?

Community Forums Forums Design Tips and Tricks Display Category Above Post Title?

This topic is: not resolved

This topic contains 9 replies, has 4 voices, and was last updated by  Dorian Speed 1 year, 8 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #5670

    ithacaindy
    Participant
    Post count: 47

    I’d like to display the category (single) of each post above the title of the post. Is there a Genesis hook for this?

    #5743

    kosmiq
    Participant
    Post count: 15

    Don’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 1 year, 8 months ago by  kosmiq.
    • This reply was modified 1 year, 8 months ago by  kosmiq.
    #5747

    ithacaindy
    Participant
    Post count: 47

    The 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.

    #5755

    ramseyp
    Participant
    Post count: 99

    Hi 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.


    #5802

    Dorian Speed
    Participant
    Post count: 140

    I’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!

    • This reply was modified 1 year, 8 months ago by  Dorian Speed.
    • This reply was modified 1 year, 8 months ago by  Dorian Speed.
    #5952

    ithacaindy
    Participant
    Post count: 47

    Didn’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?

    #6064

    ramseyp
    Participant
    Post count: 99

    You 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.


    #6073

    Dorian Speed
    Participant
    Post count: 140

    You 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!

    #6075

    ithacaindy
    Participant
    Post count: 47

    Sorry, doesn’t work. Is the only way to get what I’d like the genesis loop?

     

     

    #6096

    Dorian Speed
    Participant
    Post count: 140

    This 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!

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.