Is it possible to add widgets to custom post types archive sidebar? (4 posts)

  1. Torlock
    Posted 3 years ago #

    I have created a custom post type 'djs' and I wanted to display a menu with custom taxonomies using the plugin http://www.studiograsshopper.ch/custom-taxonomies-menu-widget/
    So that in the sidebar people could refine the result by genre and location. I am wondering if there is a way to do this or maybe an alternative.
    For example displaying the results on a page and then assigning the page a specific sidebar.
    URL: http://gummet.com

  2. Pioneer Web Design
    Posted 3 years ago #

  3. Torlock
    Posted 3 years ago #

    Hello, I have looked into what you suggested but I coan't get it to work.

    Heres what I did:

    1) Added custom sidebar using this code:

    if ( function_exists('register_sidebar') ) {
    'name' => 'Roster Sidebar',
    'id' => 'roster-sidebar',
    'description' => 'Appears as the sidebar on the roster',
    'before_widget' => '<div style="height: 280px"></div><li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',

    2) Added widget to new sidebar

    3) Created a new file called sidebar-roster.php with this code in:

    <div id="sidebar">
          if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('roster-sidebar') ) :
          endif; ?>

    4) Created a file called archive-{djs}.php and added:

    if(have_posts()) : while(have_posts()) : the_post();
    	echo '<div class="entry-content">';
    	echo '</div>';
    endwhile; endif;
    <?php get_sidebar('roster'); ?>

    I then reloaded http://gummet.com/djs/ and it still have the default sidebar.

    What am I doing wrong?

    I also found this (http://codex.wordpress.org/Page_Templates#Example_Using_Custom_Post_Types)

    Maybe this is an option? But where would I upload it and what would I call it?

    Thanks for the help :)

  4. Torlock
    Posted 3 years ago #

    Okay got a custom archive for the post type now (archive-djs.php)

    I noticed I had to make it archive-djs rather than {djs}

    But now there is no sidebar?

Topic Closed

This topic has been closed to new replies.

About this Topic