Skip to content
Advertisement

WordPress Shortcodes (Possibly Nested & Input)

I’ve been battling with this problem in WordPress particularly with using one shortcode which has a nested shortcode inside it, which works like a charm, however I wanted to make it a simple shortcode which in turn then would be easier for someone to use.

You can see the code here

JavaScript

The HTML output for the shortcode is basically this

JavaScript

What I would like to do is to use a WordPress shortcode like

JavaScript

The Year and Description could be filled out by the content editor for example. I have the shortcode working for this, but I have no idea or anywhere to start regarding inputting the data from the shortcode tag to display exactly what it should be.

Edit: Adding the solution to this for reference to whoever comes across the same problem themselves. Improving on Cyrille’s answer which has set me on the right path. I have found out that the following is more effective as it is…

JavaScript

Advertisement

Answer

You should have a look at the following link: http://codex.wordpress.org/Shortcode_API Particularly at the extract function.

You could do for instance:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement