This deck was presented in Bogotà in the WordCamp 2017 event by people who are part of the company.
Presented by: Rhonlaf Martinez, Front-end developer
4. What’s this about all
about?
● What can I use it for?
● And where do I put it on the site?
● Action (without lights and cameras?)
● Some documentation.
● Farewell.
@rhonaldomaster #WCBogota
5. Reusable snippets [shortcodes]
● Reuses ... what?
● Reusable snippet = reusable code.
● Can be used anywhere on the site.
● You do it your way.
@rhonaldomaster #WCBogota
6. I understand ... and what can I use it
for?
For whatever you need!
● Customize your site with these tools your way.
● You do not have to repeat code.
● You can do them yourself or look for some implemented code
on the internet.
@rhonaldomaster #WCBogota
7. Excellent! And how do I
create them?
● It’s code, so you can simply use your favorite editor.
● Add them to the theme's functions.php file.
● Use them on your site!
@rhonaldomaster #WCBogota
9. A shortcode is added to the site using the syntax [nameshortcode].
You can receive parameters [nameshortcode parameter = "Hello"].
You can also send content [nameshortcode] Hello Mom! [/
Shortcode].
The shortcode will return a string that will be written to the page.
@rhonaldomaster #WCBogota
10. After creating your shortcode, we tell Wordpress that we want to
use it.
To do this, we use the following instruction:
add_shortcode ('name_user', 'create_user');
In our case:
add_shortcode ('nameshortcode', 'say hi_to_mom');
@rhonaldomaster #WCBogota
11. And then what?
Now comes the simple part:
You just have to place the shortcode in the editor in your entry or
page:
@rhonaldomaster #WCBogota
12. And in your post / page you will see this:
Yes, that's it.
@rhonaldomaster #WCBogota
13. Are there any predefined shortcodes?
Sure! Wordpress has the following:
● [audio] - https://codex.wordpress.org/Audio_Shortcode
● [caption] - https://codex.wordpress.org/Caption_Shortcode
● [embed] - https://codex.wordpress.org/Embed_Shortcode
● [gallery] - https://codex.wordpress.org/Gallery_Shortcode
● [playlist] - https://codex.wordpress.org/Playlist_Shortcode
● [video] - https://codex.wordpress.org/Video_Shortcode
@rhonaldomaster #WCBogota
15. We can use these online tools
https://generatewp.com/shortcodes/
https://www.nimbusthemes.com/add-shortcode-wordpress-snippe
t-generator
@rhonaldomaster #WCBogota
16. When using the tool
Both will give us a text or code, which we must place in the file
functions.php of the theme of our site.
Then, we can use the shortcode in the input or page we want!
// Add Shortcode
function custom_shortcode() {
return '<span>Hola mamá, mira lo que hice</span>';
}
add_shortcode( 'testing', 'custom_shortcode' );
@rhonaldomaster #WCBogota