Most beginners are confused as to the true meaning of the shortcodes. Translated, this term means Short Code or shortcut », In short a code that we use to display / execute a feature quickly.
I said quickly, because these features can be displayed / executed differently, by changing the source code, but it obviously takes a lot of time.
Whether you are a developer or just a WordPress user, you need to learn how to use shortcodes. These are in most cases added by plugins / themes, but others are available by default.
These shortcodes are generally used on the visual editor or in some widgets.
How is the shortcodes
The shortcode is usually preceded by an open bracket " [ "And generally ends after a closed hook" ] ».
The shortcodes are of two types:
- Simple shortcodes, they only consist of an opening and closing hook in this style: "[shortcode]".
- Paired shortcodes are two shortcodes that are slightly different in form but remain independent of each other. They are generally used to capture very large data. They usually look like this: [Shortoce_paire] content to capture [/ Shortcode_paire]
The code shortcodes exceptionally accept parameters. This is additional information added to a shortcode. They come in this form " parameter = 'value' ". Here is an example of a shortcode with parameter:
« [parameter shortcode = 'value'] ».
Note : Paired shortcodes also accept parameters.
How to use the shortcodes available by default
These are the shortcodes provided with WordPress after its installation. It is more precisely:
For videos: [video]
This shortcode takes as parameters the following attributes:
- « src To indicate the source of the video, for example: [video src = 'http: //example.com/video.mp4']
- « mp4 To tell some browsers that the file is in mp4 format.
- « mauve To tell some browsers that the file is in mov format.
- « ogv To tell some browsers that the file is in ogv format.
- « height "," width To set the height and width of the image.
- « autoplay To enable auto play. Take a value « on " or " off ».
- « preload To enable the anticipated loading of the video. Take a value « on " or " off ».
- « loop For a reading in the shop. Take a value « on " or " off ».
For audio files: [Audio]
This shortcode allows you to add an audio player to your blog. It takes the same parameters of the video shortcode, except the parameters " height " and " width ».
For galleries: [gallery]
This shorcode allows you to create a photo gallery on WordPress. However, you must provide the identifier of the different images of your blog to the "ids" parameter, so as to have a shortcode identical to this one.
« [gallery ids = '1,200,434,50'] »
For more information, I invite you to consult this documentation available on WordPress.org.
Some plugins specializing in displaying web elements
Some WordPress plugins add functionality that allows you to display web elements. You no longer necessarily need to master the HTML/CSS language to personalize your pages.
As plugins, I can cite:
Ultimate Shotcodes
By adding this plugin to your blog, you will notice a new button insert the shortcode »Available on visual editor. In fact, this plugin adds new functionality to your blog. It's the case :
- the lightbox
- Audio files, video (Youtube video, Vimeo)
- Documents
- Articles
- user
- Turnkey templates (themes)
- Paintings
- tabs
- Accordions
- And many more functions
There are a number of things this plugin offers, and I'm sure it will make your life a lot easier.
Easy Bootstrap shortcode
Here is a rather interesting plugin, it adds new graphic features to your blog.
When I talk about graphics I am referring to the different components of the Bootstrap framework, that is to say panels, accordions, sliders, tables, images, galleries in short, a panoply of very interesting features to create a good " landing page ».
That's it for this tip on WordPress shortcodes. Feel free to share this tutorial on your favorite social networks.