WordPress Shortcode Seminar -- How to Create a Shortcode that Styles Content Text

Опубликовано: 11 Октябрь 2024
на канале: Rick Anderson
2,170
4

http://www.byobwebsite.com/answers/wo...
I recently suggested on the DIY Themes forum that a designer use a shortcode to create a couple side by side of text boxes in the content area of her home page. This is a subject I've been wanting to teach on anyway so I decided to do so here. In this seminar we'll learn about both self closing and enclosing shortcodes. We'll create two text boxes that sit side by side and are bordered with a thin grey border. The final result can be seen here. The original thread can be found on the DIY Themes forums here. There is a follow up example that creates a twitter link with icon. That example can be found here.
Video Transcript

I've had this ongoing dialogue back and forth this week with a woman on the DIY Themes forum and she wants to... I'll show you what she wants to accomplish. She wants to accomplish this on her homepage. So she's got these 4 images and those kinds of things already figured out but she's thinking she needed something special to construct these 2 blocks of text. And she wants these 2 blocks of text to be easily editable so she wants some kind of an edit screen on the homepage that would allow her to do that.

I suggested to her that rather than having something special on her homepage what she should just do is create a shortcode for the purpose of developing this and then teach the client how to use the shortcode. And so that's what I'm going to demonstrate this evening, how to create a shortcode in WordPress and then use that shortcode for a variety of things -- for styling texts in particular.

I use shortcodes on my site for things like... these little check marks here. You probably have noticed there are 3 different styles of check marks -- there's the green one which means that you're logged in and you have access to the video. There's the yellow one that means you would have access to the video if you were logged in. And then there's the red one which means you have to be logged in and a paid member in order to see the video. That is all accomplished by means of a shortcode and in fact, you can see that... I'm just going to take a look at that in my pages here. And we'll just look at one of our lesson pages, Customize Thesis Like A Pro for example. If we go to the Visual, you'll see a little thing right there that says "Public" -- that is a shortcode. And that public shortcode will always show a green check box whether you're logged in or you're not logged in because public videos don't require a log in. And so that's one of the ways in which I use shortcodes. I also use shortcodes for embedding videos and a variety of other things. For those of you who have gone through the ecommerce tutorials with me, you will recognize shortcodes from the catalog because we use shortcodes to create the catalog in WP eStore.