0

Is it possible to add my shortcode in a table?

    [vc_column_text]
        [st_custom_meta key="st_custom_available_dates"]
    [/vc_column_text]

For example, if my custom_meta has the value of

  <span>Alex</span>
  <span>john</span>
  <span>Chris</span>
  <span>Bill</span>

and this span is to go in different table cells and rows. Is this possible or am I asking for something stupid?

1 Answer 1

1

The best way to think of shortcodes is by thinking that it is a function call. And when this function is called, it renders what you asked.

For example, assume the following is the content of your post or page:

Some text here
[my_short_code]
And more text here

Now, if you do not implement the shortcode hook, the above content will be displayed as shown above.

However, in your plugin functions file (or theme, but I think shortcodes are likely part of a plugin), if you add the following hook

add_shortcode('my_short_code', 'render_my_short_code);

function render_my_short_code () {
?>
Yay
<?php
}

Then the output of your post, or your page, will be as such:

Some text here
Yay
And more text here

As you can see, when you added the shortcode hook, the shortcode is now acting as a function that renders whatever you like (The hook finds the shortcode by name, and replaces it with the content of the function attached to the hook). So, it is really up to you how you use it.

More details about shortcodes here: https://codex.wordpress.org/Shortcode

Hope this helps.

1
  • Yes I think this is quite helpful thank you so much
    – DopeAt
    Commented Mar 30, 2017 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.