Different Sidebar on a CPT Archive Index Page

Community Forums Forums General Discussion Different Sidebar on a CPT Archive Index Page

This topic is: resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Jen Baumann 1 year, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6743

    Lucas Hall
    Participant
    Post count: 5

    How do I remove the primary sidebar from (and add another created by Genesis Simple Sidebars) a Custom Post Type Archive page?

    I’ve created a CPT with a “‘has_archive’ => true,”. That page can be found here: http://landlordology.com/tips/, which is being created by a template called “archive-tips.php”

    When I try to remove the primary sidebar, and replace it with one created by the Genesis Simple Sidebar Plugin, the primary does not get removed.

    The following code isn’t working: remove_action( ‘genesis_sidebar’, ‘genesis_do_sidebar’ );

    The result is that my new sidebar (tips-sidebar) is added underneath the current primary sidebar. On the page: http://landlordology.com/tips/, the Facebook like box is the last item in the primary sidebar.

    Here is the code I’m using:

    /************************************************
    New Sidebar for Tips
    ************************************************/
    add_action(‘get_header’,’cd_change_genesis_sidebar’);
    function cd_change_genesis_sidebar() {
    if ( is_post_type_archive(‘tips’) ) { // My CPT is called tips
    remove_action( ‘genesis_sidebar’, ‘genesis_do_sidebar’ ); // remove the default genesis sidebar
    add_action( ‘genesis_sidebar’, ‘cd_do_sidebar’ ); // add an action hook to call the function for my custom sidebar
    }
    }

    //Function to output my custom sidebar
    function cd_do_sidebar() {
    dynamic_sidebar( ‘tips-sidebar’ ); // tips-sidebar is a widget area created by the Genesis Simple Sidebar plugin
    }

    This question was partially addressed by Ron but the solution doesn’t help the CPT archive/index page:http://www.studiopress.com/support/showthread.php?p=574602


    Best,
    Lucas Hall
    http://Landlordology.com

    #6941

    Jen Baumann
    Keymaster
    Post count: 444

    When you use Simple Sidebars, the actions change. If you open Simple Sidebars and look at the code, you’ll see that the standard Genesis sidebar is already removed with the following code.

    function ss_sidebars_init() {
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
    add_action( 'genesis_sidebar', 'ss_do_sidebar' );
    add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
    }


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

    #7013

    cdils
    Participant
    Post count: 423

    Hi Lucas,

    Try creating a regular ole Page and setting it to use your archive-tips.php template. There’s a dropdown box on the page where you can select which sidebar you want to use – no extra code needed. :)

    The code you’re referencing above would be if you wanted to specify the sidebar with code alone and no template (archive-tips.php).

    Carrie


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I host a weekly Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #7072

    Jen Baumann
    Keymaster
    Post count: 444

    A page template would need a custom CPT loop to work.

    http://wpsmith.net/2011/genesis/how-to-create-a-wordpress-custom-post-type-template-in-genesis/


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

    #8524

    Lucas Hall
    Participant
    Post count: 5

    Thanks you guys!  Excellent support.  I simply removed ss_do_sidebar and it worked perfectly.


    Best,
    Lucas Hall
    http://Landlordology.com

    #8591

    Jen Baumann
    Keymaster
    Post count: 444

    Glad to help!


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

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

The topic ‘Different Sidebar on a CPT Archive Index Page’ is closed to new replies.