Skip to content

Archive Sidebar Templates

Jim Reevior edited this page Aug 14, 2018 · 1 revision

Archive Sidebar Templates

Many times, a site requires a sidebar to have something special in a specific context.

For example: the sidebar on a degree program custom post type archive may need a different set of widgets than other archives (maybe with a contact form, alumni profiles, degree description, etc.). In Responsive Framework 2.0, this is now built in with no need to override the entire page template, and having an archive template is not even needed.

Sidebar Structure

Tag, Category, and Taxonomy Archives

If is_tag(), is_category(), or is_tax() is true, the following hierarchy will be used:

  • sidebar-$taxonomy_name-$current_taxonomy_term_slug-$name.php
  • sidebar-$taxonomy_name-$current_taxonomy_term_slug.php
  • sidebar-$taxonomy_name.php
  • sidebar-taxonomy-$name.php
  • sidebar-taxonomy.php

Post Type Archives

If is_post_type_archive() is true, the following hierarchy will be used:

  • sidebar-$post_type-$name.php
  • sidebar-$post_type.php
  • sidebar-post-type-$name.php
  • sidebar-post-type.php

Author Archives

If is_author() is true, the following hierarchy will be used:

  • sidebar-$author_name-$name.php
  • sidebar-$author_name.php
  • sidebar-author-$name.php
  • sidebar-author.php

Let's break these down to better understand how sidebar templates are determined.

  • $name: This is the value passed to the r_get_archive_sidebar() function. This can be used to add a level of specificity to the sidebar templates.
  • $current_taxonomy_term_slug: This is the taxonomy term slug. Example: uncategorized.
  • $taxonomy_name: This is the taxonomy's slug. Example: category.
  • $post_type: This is the post type's slug. Examples: post, page.
  • $author_name: This is the author's slug. Example: jondes.

NOTE: When searching for sidebar templates, the same methodology is applied as get_template_part() in regards to the parent/child theme hierarchy. Each template in the list above will be searched for one by one in the child theme and then parent theme.

Examples

Post Type Archive

Let's say in our theme, we need to override the sidebar on the bu_degree custom post type archive. This is the list of sidebar templates that will be searched for:

  • child-theme/sidebar-bu_degree.php
  • parent-theme/sidebar-bu_degree.php
  • child-theme/sidebar-post-type.php
  • parent-theme/sidebar-post-type.php

Welcome to Responsive!

Get started

Configuration

Build child themes

Sass

Javascript

PHP

Shortcodes

Templates

GitHub

Tasks

Contribute to the framework

Code Examples

BU Developer Resources

Clone this wiki locally