DesignMe Creative Group

207.776.5416 • MAINE & ARIZONA

fb pintrest rssicon
  • Home
  • Services
    • Websites & Social Media
    • Marketing & E-Newsletters
    • Logos & Print
    • Training & Support
  • Portfolio
    • Website Design
    • Creative Design & Branding
    • Social Media & E-Marketing
  • The Team
  • Why DesignMe?
    • Our Philosophy
    • Affordable Prices
    • Getting Started
  • Blog
  • Payment
  • Contact

March 26, 2014 By Debbie Leave a Comment

Make Your Own Shortcode

I needed to make it easy for a client to place different colored boxes behind text when she edits her new website. I could use code, of course, but the client wouldn’t know how to do that. I found this little 3 step process worked very well.

STEP ONE: Insert the following code into your functions.php file. In this case, I’m calling in a <div> with an id of “white”.

//* green box *//
function greenbox($atts, $content=null, $code="") {
$return = '<div id="green">';
$return .= $content;
$return .= '</div>';
return $return;
}
add_shortcode('green' , 'greenbox' );

STEP TWO: Create your css.

#green {
background-color: #cddc92;
width: 100%;
clear: both;
padding: 10px 25px;
padding: 1.0rem 2.5rem;
margin: 10px 0;
}

STEP THREE: Then you can insert it into your WordPress editor like this (without the spaces after/before the brackets):

[ green ]My Green Box[ /green ]

THE RESULT: My green box ends up looking like this:

My Green Box

Filed Under: Code Tips, TechTalk

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Site Search

From Our Blog

  • 10 Reasons You Need a Custom Website
  • The Squatty Dog
  • The “ME” In Our Name Really Means YOU
  • Behind Your Website
  • I Have a Website – Now What?

Tech Talk

  • Enqueue CSS2 Google Fonts
  • Redirect to the BuddyPress Profile Page
  • “Going Live”
  • Insert Soliloquy Shortcode Using Advanced Custom Fields
  • Redirect My Website To https://

Creative Corner

  • Unique Websites Deserve a Unique Login
  • Adding A Shortcode To The Post Title
  • Favicons – A Tiny Graphic With Big Impact
  • Social Media Icons – So Many Options!
  • Savage Chicken iMugs

View Topics

creative

Functional

affordable

Copyright © 2025 · Custom Website by DesignMe Creative Group · Log in
Hosted Locally by Maine Hosting Solutions