WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Torlock
    Member
    Posted 1 year ago #

    Hello,
    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.
    Thanks.
    URL: http://gummet.com

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

  3. Torlock
    Member
    Posted 1 year 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') ) {
    register_sidebar(array(
    '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">
       <ul>
          <?php
          if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('roster-sidebar') ) :
          endif; ?>
       </ul>
    </div>

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

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

    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
    Member
    Posted 1 year 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