Conditional After Post Content

Community Forums Forums General Discussion Conditional After Post Content

This topic is: not resolved

This topic contains 6 replies, has 4 voices, and was last updated by  surefirewebserv 1 year ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #34959

    smallbusinessguy
    Participant
    Post count: 2

    For after the post content (Where you can input email to subscribe), is it possible to show different content based on the post or post category? I want after post content A to appear for category A and after post content B to appear for category B.

    Can someone give me a sample code as to how to make it work?

    Thank you in advance.

    #34985

    surefirewebserv
    Participant
    Post count: 68
    #35028

    smallbusinessguy
    Participant
    Post count: 2

    Thanks.

    I did not understand the following part.

    include( ‘path/to/pwdc.html’ );
    else
    include( ‘path/to/genesis.html’ );

    I am trying to add mailchimp subscribe code (Different subscribe code for different categories). Should I include it in a particular file and call it?

    Thank you,.

    #35033

    anitac
    Participant
    Post count: 6488

    Brian Gardner has a this – http://www.briangardner.com/code/add-after-post-widget/ for adding an After Post Widget that you can use.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #35038

    smallbusinessguy
    Participant
    Post count: 2

    Hi Anitac,

    I am current using that code on my site. It’s working fine. My requirement is to show different such code based on the page people come to. E.g: A post about web design should display my web design list from mailchimp. An article about marketing should display the lead capture for my marketing list from mailchimp.

    #35041

    Summer
    Participant
    Post count: 754

    For that, I’d recommend using the Dynamic Widgets plugin, http://wordpress.org/extend/plugins/dynamic-widgets/

    I’m currently using it on several sites, and it’s very easy to control which widgets are displayed on categories, pages, etc.


    #35046

    surefirewebserv
    Participant
    Post count: 68

    @smallbusinessguy

    You can either add the code to a page or add the code to your functions file. You would replace the include paths to your new html file that you made, or you can replace the include with the actual code.

    add_action( ‘genesis_after_post_content’,'sf_affiliate_block’ );
    /**
    * Add affiliate box template to end of single post.
    *
    * If post is in Better Web Design category (190), use a different template.
    *
    * @since 1.0.0
    * @author Sure Fire Web Services
    * @link http://surefirewebservices.com/?p=1521
    *
    * @return Return null if not a single post.
    */
    function sf_affiliate_block() {
    if ( ! is_single() )
    return;

    if ( in_category( ’190′ ) ) // if in the category with an id of 190
    // echo ‘your new code’ or include your file
    else
    // echo ‘a different code’ or include your file
    }

    I use this same exact code to add my after post files. If you go on my site, anything that has to do with genesis (or is in the genesis category) will get a “built on genesis” block of text after the post, while every other post with get a “learn web design” block of text.

    Bottom line, there are multiple ways to handle this. The plugins will definitely work, (another plugin recommendation would be simple sidebars) or you can code it directly into the functions.php file. They all work.


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

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

You must be logged in to reply to this topic.