• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Display Category Above Post Title?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved

Tagged: .post-info, category, featured widget amplified, post meta, posts

  • This topic has 9 replies, 4 voices, and was last updated 10 years, 9 months ago by Dorian Speed.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • December 16, 2012 at 10:40 pm #5670
    ithacaindy
    Member

    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 #5743
    kosmiq
    Member

    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() );
    }
    }

    December 17, 2012 at 9:39 am #5747
    ithacaindy
    Member

    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.

    December 17, 2012 at 10:36 am #5755
    ramseyp
    Member

    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.


    Community • Work • Conversations

    December 17, 2012 at 2:07 pm #5802
    Dorian Speed
    Member

    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!

    December 18, 2012 at 11:40 am #5952
    ithacaindy
    Member

    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?

    December 18, 2012 at 8:00 pm #6064
    ramseyp
    Member

    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.


    Community • Work • Conversations

    December 18, 2012 at 8:59 pm #6073
    Dorian Speed
    Member

    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!

    December 18, 2012 at 9:09 pm #6075
    ithacaindy
    Member

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

     

     

    December 18, 2012 at 10:30 pm #6096
    Dorian Speed
    Member

    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!

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble