• 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 with function to remove side bar in CPT

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 with function to remove side bar in CPT

This topic is: not resolved

Tagged: CPT, Custom Post Type, simple sidebars

  • This topic has 5 replies, 2 voices, and was last updated 3 years, 7 months ago by Brad Dalton.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 15, 2019 at 10:42 am #492996
    smallfish
    Participant

    Hi I'd like to show a specific sidebar in a genesis child theme using genesis simple sidebars for a custom post type. I'm using the function below and while it does add the additional sidebar im unable to get it to remove the regular primary side bar- so both appear. Could someone perhaps see where I've gone wrong.

    Thanks

    // Swap sidebars on Advisors CPT pages
    add_action('get_header','adv_change_genesis_sidebar');
    function adv_change_genesis_sidebar() {
    if ( is_singular('advisor')) {
    remove_action( 'genesis_sidebar', 'ss_do_sidebar' );
    remove_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
    add_action( 'genesis_sidebar', 'adv_do_cpt_sidebar' );
    }
    }

    // Output new sidebar with the id 'advisors'
    function adv_do_cpt_sidebar() {
    genesis_widget_area( 'advisors' );
    }

    http://sitesprivate.org
    August 17, 2019 at 1:02 am #493013
    Brad Dalton
    Participant

    How are you generating the CPT? Code or plugin?

    You could try adding support for genesis simple sidebars to your CPT.

    Please see the comments here https://gist.github.com/cdils/9162910


    Tutorials for StudioPress Themes.

    August 17, 2019 at 7:34 am #493015
    smallfish
    Participant

    Brad thanks, I'm generating with Toolset. Adding the simple sidebars support gives me the selection meta box - but adding the new sidebar is not the issue. That part worked fine. It's removing the default side bar that im unable to accomplish.

    Any other ideas? Any one?

    Thanks again

    August 18, 2019 at 1:08 am #493019
    Brad Dalton
    Participant

    Sorry, don't use Toolset but i did test this code and it works

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );

    Tutorials for StudioPress Themes.

    August 18, 2019 at 9:22 am #493027
    smallfish
    Participant

    Yes that remove-action is in that function- even if i strip out the others and just remove 'genesis_do_sidebar" the primary sidebar still appears along with the one Ive added.

    I may give up and hide via css

    Thanks for your input though

    August 19, 2019 at 3:18 am #493034
    Brad Dalton
    Participant

    A 3rd parameter of 10 works but not when SS is active.

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar', 10 );
    

    I think this relates to the hooks used in SS.


    Tutorials for StudioPress Themes.

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

© 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