Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Just want to know on "short code"

I have a plugin on my word press site that uses short code. I am not sure what short code is. I know it is functional like Javascript. But is it just referring to lots of types of code and just functions needed for the plugin? I guess what is short code?

2 Answers

Kevin Korte
Kevin Korte
28,135 Points

Shortcodes are snippets of code in square brackets that you place in a content box, and when that page is loaded, that shortcode is turned into some other piece of code and or data.

For instance, I have use a table plugin, and I build my table in the plugin, and it gives me a shortcode for that table with a unique ID. I put that shortcode in the content box of WP for a new post, and when that post is navigated to on the front end, my table of information is shown in place of the shortcode.

So that shortcode might look like:

[custom_table_id=3]

Shortcodes can be just about anything, and do just about anything, depending on the plugin that is using them. Think of them as basically bookmarks for data from another source to be put in, right at that spot.

Form plugins are another source for a shortcode. Many form plugins, you build the form in the plugin, and than use a unique shortcode. WP will replace the shortcode with the correct form before it get's sent to the browser, and boom, you have a form.

Thank you Kevin I had heard a lot about short code but not just how it functions. I had guessed it worked something like that but not quite. I am just learning so I wanted to know what I could be talking about to future customers. Have agreat day.