Title: Shortcode for adding background to content
Last modified: August 19, 2016

---

# Shortcode for adding background to content

 *  [OM2](https://wordpress.org/support/users/om2/)
 * (@om2)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-for-adding-background-to-content/)
 * Can someone tell if there are ready made code for shortcodes to add a background
   to my content
 * For example, maybe I want my content to have a box around it and have a subtle
   shadow around the box
 * I think I know enough to be able to code myself – but I thought this is such 
   a simple thing, that someone is bound to have already coded?
 * Thanks
 * Omar

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

 *  [David Gwyer](https://wordpress.org/support/users/dgwyer/)
 * (@dgwyer)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/shortcode-for-adding-background-to-content/#post-2035775)
 * Maybe, but things like this that do exist are hard to find sometimes unless someone
   can point you in the right direction.
 * However you might want to sort the code yourself. The code below will get you
   started, just add it to your themes functions.php file or into a Plugin.
 * If you are adding it to your theme it is best to do it via a child theme, but
   you can test it works in your main theme first:
 *     ```
       // Usage: [custom-box]Content inside your custom box![/custom-box]
       function custom_box_shortcode($atts, $content=null ){
       	return "<div style=\"border: 1px solid #ccc;\">{$content}</div>";
       }
       add_shortcode('custom-box', 'custom_box_shortcode');
       ```
   
 *  [yungyeng](https://wordpress.org/support/users/yungyeng/)
 * (@yungyeng)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/shortcode-for-adding-background-to-content/#post-2036078)
 * Thank you this helps but the background remains on all the pages after that i
   want to make button like Try This and when user clicks on it the background changes
   one more click defeault ! that can be done ? thank you very much…

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

The topic ‘Shortcode for adding background to content’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [yungyeng](https://wordpress.org/support/users/yungyeng/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/shortcode-for-adding-background-to-content/#post-2036078)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
