ComputersSoftware

WordPress shortcuts: usage examples

Shortcodes WordPress are a powerful, but still little known function of the site management system. To show ads in a blog, it's enough just to type the word adsense. With the post_count command, you can instantly know the number of publications. There are many such examples. Sets of functions can greatly simplify the work of the blogger.

An example of a simple shortcode

A novice user needs to learn how to create and use special commands, and also 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 of 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 record in PHP. The user will receive a line like this: my_shortcode (array ('id' => '1', 'color' = 'white'), 'Some suggestion').

If desired, you can use the record without 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"].

Any content can be embedded in shortcodes: [url href = "http: // site / article / 322198 /% D1% 81% D1% 81% D1% 8B% D0% BB% D0% BA% D0% B0 per 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.

Appointment

With this tool you can create in the editor original themes for WordPress without HTML and special knowledge. If necessary, add buttons and sliders 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 tasks and is very useful in the work.

Creating Shortcodes

If the user knows how to print a simple PHP-function, then he easily achieves 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 the 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.

WP Shortcode by MyThemeShop

Quite recently, this free extension was distributed 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 a 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 each selection of plug-ins 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 plugin 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 and vertical 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.

Shortcoder

This plugin is also often found in different collections. 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 there . Further it is necessary to cause it in a post command [sc: adsenseAd]. The user can pass new parameters to the shortcode using the content editor.

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

Easy Bootstrap Shortcode

The plugin allows you to add new styles for the 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 web resource grid, so it has a lot of settings for the columns. A blogger can create multiple blocks, as well as specify dimensions and indents. The plug-in supports adaptive layout. The user can also work with basic shortcodes: tabs, lists, buttons, labels, sliders, etc.

WP Canvas - Shortcodes

The add-on contains a selection of the most popular feature sets for extending 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 a 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 for WordPress. After installing the software product in the top panel of the text editor, you can see the button for selecting various elements. Here there are all standard shortcodes: tabs, opening 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 shortcuts: setting up

How do I get a link to publish a post on Twitter? To do this, open the functions.php file and insert a line next to the other shortcodes in WordPress in PHP: function twittit ID). '"Title =" Share a note with your friends! " > Send ';} 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 increase the number of subscribers is to display a properly formatted 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 '

Subscription ';} add_shortcode (' subscribe ',' subscribeRss') ;.

Adding Google AdSense

Many bloggers use the contextual advertising service. Insert the code of the tool from Google into the theme file will not be difficult. But marketers know that people are more likely to follow links embedded in 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 perform this task, you need to convert the function to a 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 call up the list of articles right in the editor, you need to create a shortcode, switch to HTML mode and insert the string [liste num = "5" cat = "2"]. This command will 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 can use 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.

Add feature sets to widgets

It is worth paying attention to the fact that in the side columns of the site, not one WordPress shortcode is working. Restriction 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.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.