• 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

Afterpost widget for different 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 › Afterpost widget for different category

This topic is: not resolved

Tagged: after-post widget

  • This topic has 6 replies, 2 voices, and was last updated 12 years, 4 months ago by Victor.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • July 12, 2013 at 10:13 am #50386
    Victor
    Participant

    I am using the after post widget. I would like to be able to display different content depending on the post category.

    Example: Post category 1 displays content 1
    Post category 2 displays content 2

    Thanks in advance

    July 12, 2013 at 10:35 am #50390
    Brad Dalton
    Participant

    You can do this at least 2 ways.

    1. Using a custom field
    2. Creating multiple widgets.

    https://gist.github.com/braddalton/5985827


    Tutorials for StudioPress Themes.

    July 12, 2013 at 12:35 pm #50411
    Victor
    Participant

    Brad

    Thanks very much. Could you please clarify.

    I can cut and paste code but this is a bit confusing for me.

    The code above would create a new after post widget for category. Correct?

    Place this at the bottom of my child theme PHP file?

    Cheers

    This is the child theme php showing my existing after post widget

    http://screencast.com/t/vJeXd1slH

    July 12, 2013 at 1:00 pm #50412
    Brad Dalton
    Participant

    Victor

    Please copy the PHP code from the view raw link and paste it at the end of your child themes functions.php file.

    You will need to edit this part of the code with the slug or category i.d for one category.

    if ( in_category(007)
    

    or

    if ( in_category(web-design) 
    

    In the above example, 007 is the category i.d. and web-design is the category slug.

    This will create a widget which displays content after all posts in that specific category.

    Duplicate the solution for each category or use the other option which is to create a custom field.


    Tutorials for StudioPress Themes.

    July 12, 2013 at 1:44 pm #50426
    Victor
    Participant

    Ok that worked great

    But I must be missing something to duplicate the widget for another category.

    I tried duplicating it and it created an error.

    Do I have to rename or something?

    Thanks

    July 12, 2013 at 2:12 pm #50436
    Brad Dalton
    Participant

    Here's an example:

    https://gist.github.com/braddalton/5987428


    Tutorials for StudioPress Themes.

    July 12, 2013 at 2:48 pm #50453
    Victor
    Participant

    ok

    Thanks

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 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

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