background preloader

Shortcode

Facebook Twitter

Fr:Shortcode. Fr:Shortcode Languages: English • Français • (Add your language) Depuis la Version 2.5 WordPress supporte les dénommés Shortcodes.

fr:Shortcode

Ils ont été introduits pour créer des macros utilisées dans le contenu d'articles. Pour des exemples de shortcodes et comment les utiliser, voir WordPress.com Shortcodes (en), quoique certains shortcodes mentionnés soit exclusifs à WordPress.com. Un shortcode trivial pour une galerie ressemble à : [gallery] Vous pouvez afficher un shortcode directement depuis un modèle avec : Les shortcodes peuvent avoir des attribut additionels comme montré dans l'exemple suivant : [gallery id="123" size="medium"] Les deux exemples vont afficher une galerie d'images qu'il serait difficile de maintenir en utilisant les balises HTML et de le synchroniser avec les images téléversées.

Shortcodes Natifs et additionnels WordPress offre un panel de shotcodes par défaut (par exemple, celui de la galerie) et les extensions peuvent ajouter les leurs via la Shortcode API. Shortcode API. Languages: English • Italiano • 日本語 • Português do Brasil • Русский • (Add your language) The Shortcode API The Shortcode API is a simple set of functions for creating WordPress shortcodes for use in posts and pages.

Shortcode API

For instance, the following shortcode (in the body of a post or page) would add a photo gallery of images attached to that post or page: [gallery] The API enables plugin developers to create special kinds of content (e.g. forms, content generators) that users can attach to certain pages by adding the corresponding shortcode into the page text. The Shortcode API makes it easy to create shortcodes that support attributes like this: [gallery id="123" size="medium"] The API handles all the tricky parsing, eliminating the need for writing a custom regular expression for each shortcode. As a quick start for those in a hurry, here's a minimal example of the PHP code required to create a shortcode: This will create [foobar] shortcode that returns as: foo and bar With attributes: Overview. WordPress Shortcodes: A Complete Guide.

Advertisement WordPress shortcodes were introduced in version 2.5 and since then have proved to be one of the most useful features.

WordPress Shortcodes: A Complete Guide

The average user acting as editor has the ability to publish dynamic content using macros, without the need for programming skills. When a shortcode is inserted in a WordPress post or page, it is replaced with some other content. In other words, we instruct WordPress to find the macro that is in square brackets ([]) and replace it with the appropriate dynamic content, which is produced by a PHP function.

The usage is pretty simple. WordPress Shortcodes: A Complete Guide.