• 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

Add content before all posts in a category

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 › Add content before all posts in a category

This topic is: resolved

Tagged: add text box, custom content

  • This topic has 10 replies, 3 voices, and was last updated 11 years, 8 months ago by Brad Dalton.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • May 21, 2014 at 2:28 pm #106215
    mercurialist
    Member

    I'd like to add some custom text before the content of all posts in a specific category. I would like for this text to appear below the headline and before the post content begins.

    I have a feeling the process will be similar to what is explained here, only I'm not creating a box below the content.

    I'm using the Apparition theme. URL is not included because site is being developed offline.

    May 21, 2014 at 3:01 pm #106219
    Lauren @ OnceCoupled
    Member

    Yep, you want to use the same general concept, only you want to hook your widget area into a different location. This line add_action( 'genesis_after_post_content', 'sp_genesis_box', 9 ); should be changed to accomplish that. You can find a nice guide to the various hooks here: http://genesistutorials.com/visual-hook-guide/. You'll also need some conditional logic to check that the category ID is the one you want: http://codex.wordpress.org/Conditional_Tags#A_Category_Page.

    Best,
    Lauren


    We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com

    May 21, 2014 at 7:17 pm #106243
    mercurialist
    Member

    Thanks for your help, Lauren. Unfortunately, it's still not working, although I may have missed something when implementing this. Here's the code that I placed in functions.php:

    //* Register before post widget area
    genesis_register_sidebar( array(
    	'id'            => 'before-post',
    	'name'          => __( 'Before Post', 'apparition' ),
    	'description'   => __( 'This is a widget area that can be placed after the post', 'apparition' ),
    ) );
    
    //* Hook before post widget area before post content
    add_action( 'genesis_entry_content', 'sp_before_post_widget' );
    	function sp_before_post_widget() {
    	if ( is_single() && in_category( 'old-blog' ))
    		genesis_widget_area( 'before-post', array(
    			'before' => '<div class="before-post widget-area">',
    			'after' => '</div>',
    	) );
    }

    The widget is registered, but when I add a text widget, enter some text, and save it, nothing changes.

    May 21, 2014 at 8:58 pm #106249
    Lauren @ OnceCoupled
    Member

    Sounds like a problem with your conditional. If you try removing the conditional, does the widget area show up?


    We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com

    May 22, 2014 at 4:26 am #106289
    Brad Dalton
    Participant

    Please copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++


    Tutorials for StudioPress Themes.

    May 22, 2014 at 6:22 am #106293
    mercurialist
    Member

    Lauren: I removed the conditional and it's the same problem. I see the widget area in "Appearance>>Widgets," but I nothing changes on the page when I actually place a widget there.

    Brad: Thanks for the code. I added it to my functions.php file, only changing the category slug. Same problem, though. Widget area appears in "Appearance>>Widgets," but nothing appears on the site when I actually add a widget.

    May 22, 2014 at 8:06 am #106323
    Brad Dalton
    Participant

    I tested the code today and it works perfectly.

    Did you save the widget after populating it in the new area?

    What widget did you use?


    Tutorials for StudioPress Themes.

    May 22, 2014 at 10:06 am #106343
    mercurialist
    Member

    Yes, I saved the widget after populating it. I have experimented with a text widget, category widget, and the "meta" widget that displays meta content. Still nothing.

    It makes no sense to me why your code wouldn't work for me. Really weird.

    May 22, 2014 at 10:26 am #106348
    mercurialist
    Member
    This reply has been marked as private.
    May 23, 2014 at 5:15 pm #106554
    mercurialist
    Member

    Update: I tried Brad's code using a different child theme (Parallax Pro). The code works just fine with this theme, and it's the theme I'll be using for my project. Thanks again, Brad!

    There must be an issue with the Apparition theme that prevents the hook from working.

    May 23, 2014 at 10:58 pm #106570
    Brad Dalton
    Participant

    You're welcome.

    Will post back if i get the chance to work out why it didn't work in Apparition. Maybe there's another function using the same hook already.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Add content before all posts in a category’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 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