WordPress shortcodes are used to 1) reduce the amount of code you need to write; 2) simplify the usage of WordPress plugins, themes, and other functions. They behave like macros, when you insert a shortcode, it is replaced with a snippet of code. It could be anything. WordPress comes with some pre-defined shortcodes, like [gallery] and [caption], and they’re also included with many popular plugins and themes. You can also create your own custom shortcodes to do things like create columns on your WordPress website. In this post, we’ll take you step-by-step through the process of creating and using your own custom shortcodes. We’ll walk you through the entire process of creating a new shortcode and show you how to modify and control the shortcode attributes and functions. Please note that this is a more advanced post that will go into details on how to create shortcodes. If working with code is beyond your technical expertise, and you just want the easiest way to get started with creating and using shortcodes you may want to start with a shortcode plugin. When creating your own shortcodes, there are two things you need to do: Create the shortcode handler function. A shortcode function is a function that takes optional parameters (attributes) and returns a result. Register the shortcode handler function. Use the built-in WordPress add_shortcut function to register custom shortcodes. Preparing WordPress for Custom Shortcodes Although it’s not required, it’s a good idea to keep your custom shortcodes in their own file. Alternatively, you may add them to your theme’s functions.php file. First, create a new file named custom-shortcodes.php, and save it inside the same folder as your theme’s functions.php file. Then, inside the newly created file, add the following block of code: <?php ?> Next, open the functions.php file, and add the following line of code: include('custom-shortcodes.php'); You’re now ready to start adding your custom shortcodes. Basic Shortcodes In this first example, we’re going to create a basic WordPress shortcode that inserts the Day Of The Indie avatar image below. Creating the Shortcode The first step is to create the shortcode function. Inside the custom-shortcodes.php file, add the following block of code: function dotiavatar_function() { return '<img src="http://dayoftheindie.com/wp-content/uploads/avatar-simple.png" alt="doti-avatar" width="96" height="96" class="left-align" />'; } In the code example above, the dotiavatar_function function returns a pre-determined image named avatar-simple.png. The next step is to register the shortcode with WordPress using the built-in function add_shortcode. Still inside custom-shortcodes.php, add the following line of code: add_shortcode('dotiavatar', 'dotiavatar_function'); When you register a shortcode using the add_shortcode function, you pass in the shortcode tag ($tag) and the corresponding function ($func)/hook that will execute whenever the shortcut is used. In this case, the shortcut tag is dotiavatar and the hook is dotiavatar_function. Note: When naming tags, use lowercase letters only, and do not use hyphens; underscores are acceptable. Using the Shortcode Now that you have the shortcode created and registered, it’s time to try it out! Whenever you want the DOTI avatar to appear inside the post content, you can use the shortcode instead: [dotiavatar] Shortcodes with Parameters (Attributes) In the previous example, there wasn’t much room to change things up. Let’s say, instead of pushing a single image, we’d like to be able to set which image to use using a parameter. You can do that by adding some attributes ($atts). Once again, inside custom-shortcodes.php, add another function, like so: function dotirating_function( $atts = array() ) { // set up default parameters extract(shortcode_atts(array( 'rating' => '5' ), $atts)); return "<img src="http://dayoftheindie.com/wp-content/uploads/$rating-star.png" alt="doti-rating" width="130" height="188" class="left-align" />"; } The function above accepts a single parameter: rating. If a rating value is not passed, it uses a default string value of 5. It does this by unwrapping the array of attributes using the built-in shortcode_atts function, and combining the default values with values that may have been passed into the function. Don’t forget to register the shortcode: add_shortcode('dotirating', 'dotirating_function'); With the shortcode function created, and the hook added, the shortcode is now ready to be used inside your post content: [dotirating rating=3] Alternatively, you can omit the rating, and just go with the default value: [dotirating] And that’s it! You now know how to create self-closing WordPress shortcodes. But there is another kind you can create. Enclosing Shortcodes Up until now, we’ve been working with self-closing shortcodes. But there is another type of shortcode: enclosing shortcodes. Enclosing shortcodes allow you to use a BBCode-style format. That is, a style that looks like this: [shortcode]content[/shortcode] Enclosing shortcodes are useful for when you need to manipulate the enclosed content. For example, let’s say you have a particular style of button you use your website; you could use the HTML code to generate that button/style every time you need to use it, or you can set up a custom enclosing shortcode instead. By using an enclosing shortcode, you’re able to keep the focus on the content, rather than on the code. Creating the Shortcode Again, inside the custom-shortcodes.php file, add the following block of code: function dotifollow_function( $atts, $content = null ) { return '<a href="https://twitter.com/DayOfTheIndie" target="blank" class="doti-follow">' . $content . '</a>'; } In the code block above, the $content = null is used to identify this function as an enclosing shortcode. And, inside that function, you’re wrapping your content ($content) within the HTML code. OK, now it’s time to register the shortcode: add_shortcode('dotifollow', 'dotifollow_function'); And that’s it! Your shortcode is ready to be used. Using the Shortcode Using an enclosing shortcode isn’t much different than using a self-closing one. Like HTML, you just need to make sure you have an opening and a closing statement: [dotifollow]Follow us on Twitter![/dotifollow] Of course, this is just a basic example. You can also add parameters to an enclosing shortcode, like you do with a self-closing shortcode. Inside custom-shortcodes.php, add one more function: function dotibutton_function( $atts = array(), $content = null ) { // set up default parameters extract(shortcode_atts(array( 'link' => '#' ), $atts)); return '<a href="'. $link .'" target="blank" class="doti-button">' . $content . '</a>'; } And then register the shortcode: add_shortcode('dotibutton', 'dotibutton_function'); This new function let’s you set a link for the button using the following syntax: [dotibutton link="/bits-bytes/"]Shop Now![/dotibutton] With enclosing shortcodes, you can do a lot with very little code. A Word About Widgets By default, shortcodes are only supported in posts, pages, or custom post types; they are not supported in sidebar widgets. To add support for widgets, you need to add the following code to the functions.php file: add_filter( 'widget_text', 'shortcode_unautop' ); add_filter( 'widget_text', 'do_shortcode' ); Once you do that, you can use shortcodes in widgets- just like you do in posts/pages. Wrapping Things Up Adding your own shortcodes doesn’t take a lot of effort- especially once you understand how they’re implemented. If you want to learn more, check out the WordPress codex.
Let’s rundown the list of the top WordPress theme designers for 2017. How was this list compiled? That’s a great question! Firstly, I reviewed the 2009 list- originally compiled by Sally Strebel, co-founder of Pagely– and then I went from there. Like Sally, I used a similar criteria for compiling this list, including active installs, user reviews at WordPress.org, community participation, and how customer support requests are handled. I also visited some of my favorite WordPress sites, dug into their code, and discovered who was behind the design. This updated list focuses on the company/organization who created the design, rather than a single designer or developer. Are you a developer looking for inspiration? Here’s how to sell your first 100 themes and plugins. So, with that in mind, here are the top 20 WordPress theme designers for 2017, in no particular order: 1. FameThemes FameThemes is one of the most popular designers. They offer themes for beginners and advanced WordPress users. 2. ThemeGrill ThemeGrill was founded in 2014 by Sanjip Shah and Rabin Shrestha. They offer both free and premium WordPress themes, which are suited for many types of individuals and businesses. 3. ThemeIsle ThemeIsle was launched in November 2012 after its founding members spent one month on an actual island (Koh Lanta – Thailand). How cool is that? 4. Colorlib Colorlib was founded in mid-2013 by Aigars Silkalns. What started out as a learning experience has grown into a small team of WordPress designers and developers, supporting a variety of themes. 5. Think Up Themes Think Up Themes has a nice set of themes from which to choose. They offer single-purchase themes, bundles, and annual subscriptions. 6. Magee Magee offers free and premium WordPress themes. I’ve used their themes before, and I’d absolutely use them again. They’re easy-to-use and customize – and they’re reliable. 7. ThemeZee ThemeZee specializes in “Magazine” themes. They offer both free and premium themes. 8. WooThemes WooThemes has a bulletproof theme to get your storefront looking its best. 9. Sparkle Themes Sparkle Themes is another resource for free and premium themes. Their themes are very simple to use, and they’re all customizable. 10. Theme4Press Theme4Press offers retina-ready and woocommerce-equipped WordPress themes. 11. Webriti Webriti was founded by Ankit Agrawal and Priyanshu Mittal. They have a small group of designers and developers who create WordPress themes and Plugins for artists, bloggers, and other professionals. 12. OceanWP OceanWP is a theme created by Nicolas Lecocq. It’s a completely free WordPress theme, with a lot of extras. At the moment, it’s the only theme offered by Nicolas, but with a theme this good… what else would you need? 13. ThemePacific ThemePacific offers free and premium themes. The design and development team is headed by the Raja CRN. 14. Themefurnace Themefurnace was founded in 2012 in Manchester, England by Oliver Dale, and is owned by parent company, Kooc Media Ltd.. They have a dedicated group of designers, developers, and customer support staff if you need a hand. 15. HashThemes HashThemes offers a handful of responsive WordPress themes, backed by a dedicated support team. 16. aThemes aThemes started in 2013 with a single free WordPress theme. Now, they’re a growing team with more than 7 premium and 19 free themes. 17. SiteOrigin SiteOrigin was started by Greg Priday in 2011, which is now home to a small group of designers and developers. They offer free and premium WordPress themes, mainly for the business professional or corporate homepage. 18. LyraThemes LyraThemes offers free and premium WordPress themes. They have a design and development team, and they also offer support for their themes. 19. THEMEZHUT THEMEZHUT has about a dozen themes from which to choose. They offer high quality free and premium WordPress themes. 20. Kaira Kaira started providing web design and web development services in Cape Town, South Africa beginning in 2010. But in 2014, they scaled back their operation and shifted their focus to WordPress design and development. That does it for this list. Find out how Pagely can support your WordPress site here. Note: The WordPress community is huge; I most likely missed a few great designers. If you’re one of them, or know of someone I missed, let us know in the comments. See Sally’s original post below. ______________________________________________________________________ Original Post, published in 2009 Adil Pienaar Adil Pienaar is the co-founder of WooThemes and one of their lead designers. He’s located in Cape Town, South Africa. Brian Gardner Brian Gardner is a self taught WordPress junkie who loves Starbucks lattes and many other things. He runs StudioPress which offers premium WordPress themes. He’s located in the Chicago area. ChiQ Montes ChiQ Montes of WPThemeDesigner.com is based in the Philippines and has released numerous free themes to the public. Cory Miller Cory Miller is the CEO of iThemes and has a background in journalism, marketing, and webdesign. Evan Eckard Evan Eckard of evaneckarddesign resides in the bay area of northern California. Felix Krusch RichWP is Felix’s company. He currently resides in Montreal, Canada but loves to travel. Gisele Jaquenod Gisele has numerous WordPress themes on deviantart.com. She’s originally from Argentina but will soon relocate to Norway. Jason Schuller Jason owns Press75. He was born and raised in Seattle, Washington Jesse Wingert Jesse designs all of the themes for WPnow.com and strives to add a new theme every week. He’s also a co-founder. M. Popvici M. Popvici of Digital Nature is located in Romania Magnus Jepson Another designer of importance is Magnus Jepson of Woothemes. He’s a co-founder who lives in Norway. Mark Forrester Mark lives in London, England but is originally from South Africa. He’s a designer/ co-founder of Woo Themes. Michael Jubel Hutagalung Michael is the founder of ColorLabsProject and resides in Indonesia. Mike Durkin Mike is the CEO of Solostream. He has a background in sales, marketing, and operations. Pirelli Matteo Pirelli of banelicious lives in Italy and holds most of his work on the site DeviantArt. R. Bhavesh R. Bhavesk of PremiumThemes.net Roderick Sauskojus Roderick of Modthemes.com is the lead designer. He lives in the midwest but originated from Arizona. Roshan Roshan of Rambling Soul specializes in CSS templates but many have ported his designs into WordPress. Sawyer Hollenshead Sawyer is the founder of GFXology.com. He specializes in design and photography. Suthan Sangaralingham Suthan is the co-founder and lead designer of 1Three
CSS is a great way for web developers to keep style and content separate. You can use it for things like styling block quotes in WordPress, but it can also be so much more than that. In this article, we’ll take a look at five things you can do with advanced CSS that you may not know about and will help take your web pages to the next level. Variables: CSS Custom Properties Before we had CSS Custom Properties, we had CSS preprocessors. These include Sass, Stylus, Less, and a whole host of others. While preprocessors aren’t going away anytime soon, there’s another way to use variables within your CSS code: CSS Custom Properties. Like CSS preprocessors, CSS Custom Properties allow you to define and use variables within your CSS code, making things more DRY (don’t repeat yourself). However, there are a few benefits to using CSS Custom Properties: Native support. You don’t need a preprocessor. Cascading. You can easily override values inside selectors. Live updates. You can change values inside media queries and you can access variables in JavaScript. Let’s pull apart how CSS Custom Properties are created and used. The first step is to set the value. How to set the value Before setting a value, you must first decide on a property name. Then, prefix that name with --. For example: :root { --primary-color: #752914; --secondary-color: #6397AF; } In the example above, there are two properties: primary-color and secondary color. The second step is to use the property in the style sheet. Accessing the value inside the variable To retrieve and use the values stored inside a property, you must call the var() function, and then pass in the property name: .square-left { background: var(--secondary-color); } .square-right { background: var(--primary-color); } In the example above, the background values get set to the appropriate color. The cool thing is… you can call that property from anywhere within the style sheet, and if the value ever needs to change, you only need to update it in one place. Layout & Display: Flexbox Long ago web developers had to use some interesting tricks to get things to look good. We relied mostly on tables — and in some case tables inside tables — to help. Then, one day, the div was born, and things got better. But it didn’t stop there. With CSS3, a new concept was introduced: Flexbox. The Flexbox doesn’t replace the div; it extends its capability. In fact, the concept of the Flexbox is more about the layout mode rather than the element. When working with a Flexbox, there are three things to consider: flex containers, flex items, and flex lines. As you might have guessed, a flex container holds the flex items, and those items are positioned along a flex line, of which there is only one per container. Let’s take a look at an example: .container { background: #E6E6E6; display: flex; flex-direction: column; align-items: center; padding: 5px 10px; } In the example above, a div is being defined as a flex container; its direction is set to display the items in a column; and its items are set to be center aligned. The result would look like this: If you were to change the flex-direction to row, which is the default value, the result would look like this: With a Flexbox, you’re able to have greater control with your layout and design. This helps when you’re dealing with different screen sizes and devices. Find out more about the Flexbox, along with its other properties, at W3Schools. Selectors: nth-child and nth-last-child Have you ever had a group of elements you wish you could examine, and then take some type of action based on its location within that group? Guess what? You can with nth-child and nth-last-child. Let’s take a look at how :nth-child(n) works. .circle:nth-child(even) { background: var(--secondary-color); } In the example above, every even-numbered element is being selected, and then having its background set to the value stored in --secondary-color. Of course, you can also use the keyword odd to select the odd-numbered ones too. .circle:nth-child(odd) { background: var(--primary-color); } Or, you can select a particular element using its numerical position (index) by passing in the appropriate value: .circle:nth-child(1) { animation: clacker-l .5s linear infinite alternate; } In the example above, this selects the first element. If you’d like to start the count from the last child element, you can using :nth-last-child(n): .circle:nth-last-child(1) { animation: clacker-r .5s linear infinite alternate; } In this example, the last child element will be selected. If you wanted to select the second-to-last, you’d use .circle:nth-last-child(2) instead. There are a variety of CSS Selectors available to help us write more efficient CSS code. These happen to be my two favorite, and the ones I use the most. For more information, and to see a complete list of selectors, check out the CSS Selector Reference at W3Schools. CSS Animations One of my favorite things about CSS is having the ability to animate elements; and it’s more than just moving elements on the screen. You can even use CSS Animations to smoothy change how an element appears. For example, it’s color. Working with animations requires a few steps. You first need to set up and define your keyframes and then you need to define the animation properties, such as timing, iteration, and direction. Once that’s done, you attach the animation to an element. You can also re-use keyframes and bind these to new animations/elements. Creating Keyframes Keyframes are what you use to define your CSS animation. Basically, this is where you set the various stages of your animation — in other words, the from->to state — and where you name it: @keyframes clacker-m { from { background: var(--primary-color); } to { background: var(--secondary-color); } } In the example above, the animation is named clacker-m, and it animates the element’s background from the valued stored in primary-color to the value stored in secondary-color. The keyword words from and to are commonly used to indicate the starting and ending points of the animation, but you do not need to use these. Alternatively, you can use percentages: @keyframes clacker-m { 0% { background: var(--primary-color); } 100% { background: var(--secondary-color); } } You can even add additional keyframes which will be called throughout the duration of the animation at the percentage-point specified: @keyframes clacker-m-alt { 0% { background: var(--primary-color); } 25% { background: #5BB649; } 100% { background: var(--secondary-color); } } Setting the animation properties Once you have the keyframes defined, the next step is to set up the animation properties. The animation properties determine how the animation will run. They include: animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function You may set each of these individually, or you may use the animation shorthand. Take a look: animation-name: spin; animation-duration: 3s; animation-timing-function: linear; animation-delay: 0.5s; animation-iteration-count: infinite; animation-direction: reverse; animation-fill-mode: both; animation-play-state: paused; In the example above, each property is set individually. If you wanted to use the shorthand, it would look like this: animation: spin 3s linear 0.5s infinite reverse both paused; The order in which each property is specified is not important. However, you should always start with the animation name first. In addition, you may choose to omit the optional properties and properties for which the default values are used. Attaching the animation to an element If you’re wondering where you set those animation properties and how you bind it to an element, that’;s done when you define the class the element is using: .square-right { animation: spin 6s linear infinite paused; } In the example above, the animation is bound to the .square-right class, which is being used on a div: <div class="squares"> <div class="square square-left">Left</div> <div class="square square-right">Right</div> </div> If you wanted to reuse that same animation on another div, or perhaps run it in the opposite direction, you could do so like this: .square-right { animation: spin 3s linear infinite reverse; } For more information about CSS Animations, check the CSS3 Animations Reference at W3Schools. Note: The CodePen demo uses CSS Transformations which will be explained in the next section. CSS Transformations One of the most powerful things you can do with CSS is transform your elements. Transformations can be done in 2D or 3D space, and can include things like position, rotation, scaling, skewing, and perspective. They can be used with static designs and CSS animations. For example, if you wanted to create a rotating 3D box, you can start with a single square shape, and then rotate and translate each square (side) to achieve this 3D effect. The relevant CSS code would look something like this: .s1 { transform: translateZ(-60px); } .s2 { transform: translateY(-60px) rotateX(90deg); } .s3 { transform: translateY(60px) rotateX(90deg); } .s4 { transform: translateZ(60px); } .s5 { transform: translateX(-60px) rotateY(90deg); } .s6 { transform: translateX(60px) rotateY(90deg); } In the example above, each element is translated on the appropriate axis and then rotated according to which side of the box it completes. You then need to set the perspective and transform style: /* on the container */ perspective-origin: 50% 50%; perspective: 1200px; /* on the element */ transform-style: preserve-3d; Once that’s done, you create the keyframe animations: @keyframes rotate { 100% { transform: rotateX(360deg) rotateY(360deg) translateZ(40px); } } Finally, you attach the animation to the element: animation: rotate 8s linear infinite backwards; You now have a fancy looking rotating 3D box, all done in CSS. This has only scratched the surface with what can be done with transformations. For more information, see the CSS3 2D Transforms and CSS3 3D Transforms references at W3Schools. Conclusion When you combine transformations with animations, and then bring in the power of custom properties, flexible display settings, and better ways to target and select elements, your web pages will come to life. Today, more than ever, some incredible things are being done with online content. Many of those things are possible using only CSS and HTML. It’s true what they say: you’re really only limited by your imagination. Happy CSS’ing.