Support

Home Forums Event Espresso Premium Can I create a shortcode that will just insert a block of html into an event?

Can I create a shortcode that will just insert a block of html into an event?

Posted: January 15, 2020 at 6:20 pm


Terry Lund

January 15, 2020 at 6:20 pm

We have some common “elements” for each of our events, such as a list of “Items to Bring”. I would like to be able to “insert” the html code that describes the various items to bring by actually inserting the [ITEMS_TO_BRING]. This way we store that set of html in one place, where we can edit if if/when it changes, and have the changes automatically appear in any Event using that shortcode. There’s no coding functionality needed, just raw html is fine.


Josh

  • Support Staff

January 15, 2020 at 6:46 pm

Hi,

Yes you can with a tiny bit of PHP wrapped around that html. Some example code follows:

function tl_sample_shortcode() {

  $list = 'item 1, item 2, item 3, item 4, and so on';

  $html = '<div class="list">';
  $html .= $list;
  $html .= '</div>';

  return $html;

}
add_shortcode( 'ITEMS_TO_BRING', 'tl_sample_shortcode' );

You can add the above to a functions plugin. Then go in to edit the plugin whenever you need to update the list.

Alternatively you could look at a plugin like this one:

https://wordpress.org/plugins/ultimate-shortcodes-creator/

The support post ‘Can I create a shortcode that will just insert a block of html into an event?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso