Title: Variable sidebar content trouble
Last modified: August 20, 2016

---

# Variable sidebar content trouble

 *  [lola rennt](https://wordpress.org/support/users/laurenserge/)
 * (@laurenserge)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/variable-sidebar-content-trouble/)
 * Hi I have some trouble constructing a variable sidebar.
 * On my theme I use a variable sidebar that displays all the posts. On the homepage
   it displays all the posts, on the category archive it displays the posts of that
   category. So far all good.
 * My problem now is that when I am in the category template and I click on a post,
   my sidebar relinks me to my index.php file by which the selection in the sidebar
   is lost. It should keep that selection of the category archive – but WordPress
   links to the single.php file. How can I force the sidebar to either stay in the
   category archive or retain that selection?
 * Here is my code for the sidebar:
 *     ```
       <?php
       if ( is_category('editie') ) {
       	include 'sidebar-cat-editie.php';
       } elseif ( is_category('publicatie') ) {
       	include 'sidebar-cat-publicatie.php';
       } elseif ( is_category('tentoonstelling') ) {
       	include 'sidebar-cat-tentoonstelling.php';
       } else {
       	include 'sidebar.php';
       }
       ?>
       ```
   
 * And here is a link to the online version: [http://www.thecitizenspeech.com.web02-shared05.priorweb.be/](http://www.thecitizenspeech.com.web02-shared05.priorweb.be/)
   Click on the E, P or T to visit a category archive, then click on the post to
   see what happens.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [lola rennt](https://wordpress.org/support/users/laurenserge/)
 * (@laurenserge)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/variable-sidebar-content-trouble/#post-2259445)
 * Basically I would need something like wordpress/archive/category/single
    I know
   this does not exist, but how can I tell my sidebar that if the single.php is 
   reached from a category archive it should retain that specific sidebar for the
   categoyr archive?
 * Any help is welcome, even just a simple direction.
 *  Thread Starter [lola rennt](https://wordpress.org/support/users/laurenserge/)
 * (@laurenserge)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/variable-sidebar-content-trouble/#post-2259643)
 * Can somebody help me?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Variable sidebar content trouble’ is closed to new replies.

## Tags

 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [template](https://wordpress.org/support/topic-tag/template/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 2 replies
 * 1 participant
 * Last reply from: [lola rennt](https://wordpress.org/support/users/laurenserge/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/variable-sidebar-content-trouble/#post-2259643)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
