• 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

HELP! I need assistance from a conditional statement guru!

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 › General Discussion › HELP! I need assistance from a conditional statement guru!

This topic is: not resolved
  • This topic has 8 replies, 2 voices, and was last updated 9 years, 7 months ago by Bill.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • March 26, 2017 at 11:22 am #203835
    Bill
    Participant

    I want to add a genesis widget area at the bottom of my content area, but I want it to only show in this manner:

    1) display widget area on the bottom of pages and NOT posts

    2) display the widget area on the bottom of two custom post types....a custom post type called "cpt1" and also another custom post type called "cpt2"

    3) but I also want to EXCLUDE the widget area on different custom page templates I created called "page-template-1" and "page-template-2"

    This is what I came up with but, in application, it does not exclude the widget area in the page templates listed in #3.

    // Add after entry widget to posts and pages
    add_action( 'genesis_after_entry', 'mcq_after_entry' );
    function mcq_after_entry() {

    if ( is_singular( array ('page', 'cpt1', 'cpt2')) && !is_page_template ( array ('page-template-1', 'page-template-2') )) {
    genesis_widget_area( 'content-bottom', array(
    'before' => '<div class="content-bottom widget-area">',
    'after' => '</div>',
    ) );
    }
    }

    Anyone know what I am doing wrong?

    March 26, 2017 at 11:31 am #203836
    Brad Dalton
    Participant

    Change the && to || and make sure you use the correct page template conditionals


    Tutorials for StudioPress Themes.

    March 26, 2017 at 11:44 am #203837
    Bill
    Participant

    Thank you for the reply Brad. I looked at the conditionals for the page template...I thought that was right when I wanted to include two different page templates to exclude. What do you see wrong with it?

    Also, I thought the || was for the term "OR", not "IN ADDITION TO". I need it to be treated like "IN ADDITION TO". Am I wrong in thinking that?

    March 26, 2017 at 11:49 am #203838
    Brad Dalton
    Participant

    Link to the templates please


    Tutorials for StudioPress Themes.

    March 26, 2017 at 2:03 pm #203843
    Bill
    Participant

    I created two genesis page templates to be able to display property listings generated from a real estate idx plugin. I created the templates, then assigned the templates in the idx plugin admin area.

    one template is for listing results like this:

    the other template is for details for individual property listings like this:

    Here is a link to the actual template files
    https://www.dropbox.com/sh/kgste23wj4oiy6b/AACUW81wm5k2xOzHAbn_f94va?dl=0

    in my initial inquiry above, I changed the name of the cpt's and the page templates for simplicity....but in my testing I do change them to the appropriate CPT names and appropriate template names.

    FYI: The sidebar (found and assigned in these template files) is not the widget area I am talking about in my inquiry. Those are assigned to switch out the primary sidebar for these template pages. MY inquiry is about eliminating a content-bottom widget area for these template pages.

    March 26, 2017 at 3:03 pm #203847
    Brad Dalton
    Participant

    Try adding the filenames as the i.d's like this:

    if ( is_singular( array ( 'page', 'cpt1', 'cpt2' ) ) || is_page_template( array( 'idxpress-results-template.php', 'idxpress-details-template.php' ) ) )
    

    Tutorials for StudioPress Themes.

    March 26, 2017 at 3:39 pm #203848
    Bill
    Participant

    Hi Brad... that didn't work either. whether or not I have the .php at the end for each template name makes no different.

    Let me ask this then....if I eliminate the page template array and leave it as this....

    
    // Add after entry widget to posts and pages
    add_action( 'genesis_after_entry', 'mcq_after_entry' );
    function mcq_after_entry() {
    
     if ( is_singular( array ('page','cpt1','cpt2') ) )
            genesis_widget_area( 'content-bottom', array(
                'before' => '<div class="content-bottom widget-area">',
                'after'  => '</div>',
            ) );
    	} 
    

    is there a different function I can use to eliminate this sidebar on the two different page templates?

    March 26, 2017 at 3:46 pm #203849
    Brad Dalton
    Participant

    Try using the id's like this

    page-template-idxpress-details-template-php

    and

    page-template-idxpress-results-template-php

    These aren't for a custom post type are they?

    You can set the full width layout on any edit page screen

    or

    Conditionally set the layout to full width using code

    You are adding the code to functions.php right?


    Tutorials for StudioPress Themes.

    March 26, 2017 at 5:54 pm #203851
    Bill
    Participant

    Hi Brad... that didn't work either....but, I was able to accomplish it by going about it a different way (not sure why it took me so long to realize this method)....

    I eliminated the second array for the page templates in the functions file, and then just removed the widget in the actual page template itself. ....Works like a champ.

    Thank you for your assistance!!!

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘General Discussion’ 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

© 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