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/

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: publish

Updated by  Josh 5 days, 6 hours ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!