Using Genesis Simple Sidebars Plugin To Add New Sidebar To Custom Taxonomy Archive Page

In this post, we’ll look at adding a custom sidebar to a custom taxonomy archive page.

This post assumes you have added a custom post type to your theme which supports creating custom taxonomy archive pages.

A custom taxonomy archive page is like a category archive page for your custom post type.

Remove Full Width Layout Code From Archive Template

The first step is to open your taxonomy-portfolio-type.php file and remove this line of PHP code which forces a full width layout on custom taxonomy archive pages:

//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

If you don’t remove this code, you cannot display a sidebar on your archive.

Create Custom Sidebar

The 2nd step is to create a custom sidebar using the Genesis Simple Sidebars plugin.

In this example, i have created a sidebar using the i.d ctt-sidebar.

Genesis Simple Sidebars i.d

Here’s the line of code from the below snippet which needs to include the custom sidebar i.d which in this case is ctt-sidebar:

Related Tutorials


Comments

9 responses to “Using Genesis Simple Sidebars Plugin To Add New Sidebar To Custom Taxonomy Archive Page”

  1. Hi Brad,
    Thank you! Your articles are very informative and your name keeps coming up in the SE’s for all kinds of genesis mods. It’s very helpful.

    I would like to accomplish a unique sidebar for this purpose, This works great for one sidebar, however instead of just one taxonomy, how would I change the code so there is a conditional for say three different taxonomies of a CPT… in the case that you want a different sidebar in each of the three taxonomies?

    In my example, the CPT is called ENGINES
    and I have three taxonomies for it: NEW, USED, & REBUILT

    I tried coming up with a conditional to fire off a different simple sidebar for each of the three taxonomies, but I failed.

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Bill

      Rinse and repeat the code

      With unique i.d’s for the taxonomy and sidebar i.d
      [code]
      if ( is_tax(ctt-archive) ) {

      genesis_widget_area( ‘ctt-sidebar’ )
      [/code]

      And unique functions names

      1. Thanks for the fast reply Brad….
        that is what I tried originally before posting in the comments, but I clearly am doing something wrong.

        I tried this first:
        [code]
        //* Add custom sidebar to custom taxonomy type archive ex.) Used Equipment
        add_action( ‘get_header’, ‘add_custom_tax_archive_sidebar’ );
        function add_custom_tax_archive_sidebar() {

        if ( is_tax(‘equipment-type’) ) {

        remove_action( ‘genesis_sidebar’, ‘ss_do_sidebar’ );
        add_action( ‘genesis_sidebar’, ‘custom_taxonomy_archive_sidebar’ );
        }
        }
        function custom_taxonomy_archive_sidebar() {
        genesis_widget_area( ‘used’ );
        }

        //* Add custom sidebar to custom taxonomy type archive ex.) New Equipment
        add_action( ‘get_header’, ‘add_custom_tax_archive_sidebar1’ );
        function add_custom_tax_archive_sidebar1() {

        if ( is_tax(‘equipment-type’) ) {

        remove_action( ‘genesis_sidebar’, ‘ss_do_sidebar’ );
        add_action( ‘genesis_sidebar’, ‘custom_taxonomy_archive_sidebar1’ );
        }
        }
        function custom_taxonomy_archive_sidebar1() {
        genesis_widget_area( ‘new’ );
        }

        //* Add custom sidebar to custom taxonomy type archive ex.) Rebuilt Equipment
        add_action( ‘get_header’, ‘add_custom_tax_archive_sidebar2’ );
        function add_custom_tax_archive_sidebar2() {

        if ( is_tax(‘equipment-type’) ) {

        remove_action( ‘genesis_sidebar’, ‘ss_do_sidebar’ );
        add_action( ‘genesis_sidebar’, ‘custom_taxonomy_archive_sidebar2’ );
        }
        }
        function custom_taxonomy_archive_sidebar2() {
        genesis_widget_area( ‘rebuilt’ );
        }

        But, I got a simple sidebar for each of the three taxonomies in the sidebar area

        so then I
        REPLACED THIS:
        if ( is_tax(‘equipment-type’) ) {

        WITH THIS (in order to target just the one taxonomy):
        if ( is_tax(‘equipment-type’, ‘used’ )

        (and I did this for the other two as well with the appropriate specific taxonomy)
        if ( is_tax(‘equipment-type’, ‘new’ )
        if ( is_tax(‘equipment-type’, ‘rebuilt’ )

        [/code]
        I thought this would work, but I kept getting errors.

        1. Brad Dalton Avatar
          Brad Dalton

          [code]
          if ( is_tax(‘equipment-type’, ‘new’ )
          if ( is_tax(‘equipment-type’, ‘rebuilt’ )
          [/code]
          This is wrong. Simply copy the process i used 3 times.

          Should be:
          [code]
          if ( is_tax(‘taxonomy-slug’ )
          [/code]

  2. Herb Trevathan Avatar
    Herb Trevathan

    Great Post : )

    Hey, do you have post showing how to reorder CPT’s in the admin panel with priorities?

    1. Brad Dalton Avatar
      Brad Dalton

      Hey Herb,

      Don’t think so but you can add query sets to-reorder on the archive page.

      Not sure i understand the question properly.

      1. Herb Trevathan Avatar
        Herb Trevathan

        sorry, kinda tired today – like if I have CPT’s added with different names like portfolio, and then another added CPT named projects, is there a way to re order those and control which one is on top in the admin sidebar?

        1. Brad Dalton Avatar
          Brad Dalton

          Here’s an easy solution http://wordpress.org/plugins/admin-menu-editor/

          You probably wanted code which i don’t have at the moment however i think you should be able to add a parameter in the action which controls this. Never done this before but will give it a go once i get my new computer. On someone else’s at the moment as my Dell has crashed and is beeping without the screen working.

        2. Brad Dalton Avatar
          Brad Dalton

          Just worked this out Herb.
          [code]
          ‘menu_position’ => 1,
          [/code]

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.