Title: Calling multiple sidebars by state
Last modified: September 1, 2016

---

# Calling multiple sidebars by state

 *  [prephoops](https://wordpress.org/support/users/prephoops/)
 * (@prephoops)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/calling-multiple-sidebars-by-state/)
 * Hello,
 * We have a website (www.prephoops.com) where content is published by our writers
   to a specific state. We would like to have specific sidebars for each state that
   is displayed depending on the state location of the post. For example, a Minnesota
   article would display a Minnesota sidebar, Iowa would display the Iowa sidebar,
   and so forth.
 * We currently have sidebars that are specific to each state homepage and we are
   trying to replicate that functionality for posts rather than homepages.
 * I was able to create the widget areas for the articles using the following code:
 * foreach ($state_pages as $page)
    { // ARTICLE SIDEBAR register_sidebar(array(‘
   name’ => __( $page->post_title . ‘ – Articles > Sidebar’, ‘prephoops’ ), ‘id’
   => $page->post_name . ‘_article_sidebar’, ‘description’ => ”, ‘before_widget’
   => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ”, ‘before_title’ 
   => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’, ));
 * Now I’m having trouble getting the post to pull in the correct widget area depending
   on the state. So basically, each time an article is posted, the state is selected
   and from there the correct sidebar needs to be pulled in.
 * If anyone has suggestions on how to make this work, it would be greatly appreciated.
   Thanks!

The topic ‘Calling multiple sidebars by state’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [prephoops](https://wordpress.org/support/users/prephoops/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/calling-multiple-sidebars-by-state/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
