Title: Design problem when using PHP code in widgets
Last modified: August 19, 2016

---

# Design problem when using PHP code in widgets

 *  [henigushi](https://wordpress.org/support/users/henigushi/)
 * (@henigushi)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/design-problem-when-using-php-code-in-widgets/)
 * I am trying to customize my sidebar based on the category of the post that is
   currently being read. For example, I have videos that appear in the sidebar on
   my homepage, but when the user clicks on the Videos category, I don’t want him
   to see videos again appear in the sidebar. I’ve managed to do this successfully
   by using a plugin that enables me to put PHP code into a widget, and using conditional
   tags in the widgets.
 * The problem I’m having is one of design. I want the widgets in my sidebar to 
   be visually separated — e.g., have the Categories widget in its own <div> frame,
   which makes it distinct from the Recent Posts widget. This works fine so long
   as I don’t use custom PHP code widgets. When I do, all of the content visually
   combines. If, for example, I write code in one custom PHP widget that calls Recent
   Posts belonging to the same category as the post being read, and then write another
   custom PHP widget that shows, say, an image for that category, the image and 
   Recent Posts appear in the same <div> frame, right next to each other.
 * I’d be grateful for any ideas on how to get around this but still using custom
   PHP widgets. My apologies if the above is confusing; it’s probably because I’m
   confused. Thanks in advance for any help.

The topic ‘Design problem when using PHP code in widgets’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [henigushi](https://wordpress.org/support/users/henigushi/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/design-problem-when-using-php-code-in-widgets/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
