WordPress shortcuts: usage examples

Shortcodes of WordPress are powerful, but so farlittle known function of the site management system. To show ads on the blog, just type the word adsense. With the post_count command, you can instantly know the number of publications. There are many such examples. The feature sets can greatly simplify the work of the blogger.

shortcode wordpress

An example of a simple shortcode

A novice user needs to learncreate and use special commands, as well as be able to apply ready-made options. To do this, you need to understand what the shortcodes of WordPress consist of. As an example, you can take the string [my_shortcode id = 1 color = white] Some suggestion [/ my_shortcode]. In this entry, the user calls an option that is tied to the shortcode. A string consists of two parameters.

The first part of the record is an array consisting offrom the id and color attributes. Instead of these values ​​in the opening tag, you can specify any parameters with the desired names. The second part of the record is text. In order to process it, you need to translate the entire entry in PHP. The user will receive a line like this: my_shortcode (array ("id" => "1", "color" = "white"), "Some suggestion").

If you want, you can use the recording withoutof the above closing tag. The line will look like this: [my_shortcode id = 1 color = white]. In this case, only the attributes listed in the opening tag are passed to the function. The specified variant of the record is used when calling an option that does not need to receive other information for processing. In order to add a gallery, it is enough to specify in the ID attributes.

How to insert a shortcode in WordPress

The use of function sets is very simple. A blogger needs to create a new post or open an existing record for editing. Then you need to switch the text editor to HTML mode and specify the code in square brackets: [showcase]. You can also use attributes. The entry will look like this: [showcase id = "1"].

In shortcodes, you can embed any content: [url href = "link to the site"] text [/ url]. WordPress 2.5 introduced a feature set called the Shortcode API. After saving the post, the content of the record is processed. In parallel, Shortcode API converts shortcodes to perform the functions assigned to them.

how to insert a shortcode in wordpress


With this tool you can create ineditor of original themes for WordPress without HTML and special knowledge. If necessary, buttons and sliders are added in the accordion style. The user can split the text into columns, connect the gallery, select words with any color, insert beautiful lists and tables with quotations. Shortcodes allow you to make the blog more functional, and the material - expressive and effective. This way of adding interactive elements is used to solve many problems and is very useful in the work.

Creating Shortcodes

If the user knows how to print a simplePHP-function, then it will easily achieve the goal. To create a shortcode, you need to find and open one of the WordPress functions.php files. Then you need to insert the string function hello () {return "Hello, world!";}. This action will create a function responsible for displaying the specified text. To transform it into a shortcode, you need to add the add_shortcode () command after the "hello ()" option.

The line will look like this: add_shortcode ("hw", "hello") ;. After creating a shortcode, the user can use it in notes and on pages. To do this, switch to HTML mode and enter the string [hw]. This shortcode is a good example of how easy it is to create such sets of functions.

Using plugins

To make it easier, the blogger can download the extension. Using add-ons is the easiest way to get ready-made sets of functions without unnecessary settings.

shortcode wordpress plugin

WP Shortcode by MyThemeShop

Just recently this free extensiondistributed as a premium solution. Now the WordPress shortcuts plug-in contains 24 basic elements: buttons, geographic maps, delimiters, price tables and much more. To start the blogger, you need to install the add-on and open a text editor. To add a shortcode, click on the "+" icon. The number of settings in the pop-up window that appears will depend on the user's choice.

For the button, you can specify a link and text. After adding a shortcode, an entry will appear in the editor that contains the item type and parameters. You can notice that it's quite easy to use the plugin.

Shortcodes Ultimate

This is one of the most popular extensions. The add-on is found in every selection of plugins for setting up WordPress. Expansion is available to every user. If necessary, plug-in add-ons are added to the plug-in. A blogger can work with 50 page layout elements, a shortcode generator and CSS style editor.

The plug-in has support for several languages. The advantages of the software product also include integration with any templates, modern design, original design of buttons, the presence of a custom widget and sliders for the gallery.

Fruitful Shortcodes

This extension is visually simple enough. The software product is updated infrequently. However, the add-on contains all the standard WordPress shortcodes.

The blogger can work with horizontal andvertical tabs, columns, separators, etc. The added elements are instantly displayed in the graphics editor. The user can turn them off for posts or web pages using the "Settings" section.

wordpress configuration


This plugin is also often found in differentselections. The extension is updated very rarely. The user can create sets of functions using HTML and JavaScript codes. One of the simplest examples is the placement of an ad unit in the text. To do this, create a set of adsenseAd functions.

Then you need to add the ad unit code. Next, you should call it in the post with the [sc: adsenseAd] command. The user can pass new parameters to the shortcode using the content editor.

Shortcoder is a very flexible tool. Here it will not be possible to find basic shortcodes. The user can create the necessary elements himself.

Easy Bootstrap Shortcode

Plugin allows you to add new styles of designfor site. The developers claim that this is the simplest and most accessible extension in WordPress. The text editor toolbar contains buttons that you can use to copy and paste shortcodes. The plugin has support for fonts with icons. The user can add styles and other elements of the design of the site.

The extension was created to work with the gridweb resource, so it has a lot of settings for the columns. A blogger can create multiple blocks, as well as specify sizes and indents. The plug-in supports adaptive layout. The user can also work with basic shortcodes: tabs, lists, buttons, labels, sliders, etc.

shortcode wordpress php

WP Canvas - Shortcodes

The supplement contains a selection of the most popularsets of functions to expand the functionality of the site. Not only ordinary elements are available to the blogger, but also frames, images with captions, feedback adding units, countdown widgets, process indicators with effects, and so on.

The plugin supports custom styles,HTML-code, fonts with icons. If desired, the blogger can turn on the display of the selection of site posts on the page. Developers provided users with only a brief description of the software product. In this case, the plugin copes with all the functions assigned to it.

Arconix Shortcodes

The extension contains 6 types of WordPress shortcodes. The user can work with blocks, tabs, buttons, sliders, etc. The plugin supports fonts with icons. If desired, the blogger can change the form of the login, turn on the backlight, split the page into columns.

Simple Shortcodes

This is one of the simplest extensions forWordPress. After installing the software product in the top panel of the text editor, you can see the button for selecting various elements. There are all the standard shortcodes: tabs, lists, icons, notifications, etc.

After the blogger learns how to create and use feature sets, he can focus on ready-made solutions for the site.

wordpress does not work shortcode

WordPress shortcuts: setting up

How to display a link for the publication of a post insocial network "Twitter"? To do this, open the functions.php file and paste a line next to the other shortcodes in WordPress in PHP, as follows: function twitt () {return "<div id =" twitit "> <a href =" login page = Currently reading ". get_permalink ($ post-> ID). "" title = "share a note with your friends!"> send </a> </ div> ";} add_shortcode (" twitter "," twitt ") ;.

Then you need to switch to HTML mode. Next, enter the word [twitter]. The link will be added to where the user left the shortcode.

A set of functions "subscribe to RSS"

One of the most effective ways to increasenumber of subscribers is the display of the correct message. The blogger does not need to change the entire WordPress theme code. The user must decide for himself where the set of functions will be displayed. The code looks like this: function subscribeRss () {return "<div class =" rss-box "> <a href="link to the site "> Subscription </a> </ div>";} add_shortcode ("subscribe", " subscribeRss ") ;.

themes for wordpress

Adding Google AdSense

Many bloggers use the contextualadvertising. Insert the code of the tool from Google into the theme file is not difficult. But marketing experts know that people often go over links embedded in the content. To insert an ad unit anywhere on the page, you need to create a shortcode and call it with the [adsense] command.

Adding an RSS feed

To accomplish this task, you need to convertfunction in shortcode. Then you need to enable the HTML mode and insert the line [rss feed = "link" num = "3"] in the editor field. The first attribute points to the URL of the RSS feed, and the second to the number of notes to output.

Adding posts from the database

To bring up a list of articles right in the editor,you need to create a shortcode, switch to HTML mode and insert a string [liste num = "5" cat = "2"]. This command will allow you to display a list of five posts from the category with ID 2. It should be noted that WordPress plug-ins can display linked records. However, using a shortcode, the blogger will easily get a list of any number of publications from a separate category.

Calling the picture of the last article

To simplify the work with images, you canuse function sets. To call the last post, you need to create a shortcode. Then you should enable the HTML mode and insert the line [postimage size = "" float = "center"] in the edit field.

Adding feature sets to widgets

It is worth paying attention to the fact that in the lateralcolumns of the site, no shortcode WordPress does not work. The limitation of the platform can be circumvented. To do this, open the theme file for WordPress functions.php and insert the line add_filter ('widget_text', 'do_shortcode') ;. Shortcode will be added to the widget.