Home › Forums › Calendar Products › Events Calendar PRO › Event List is not displaying shortcodes correctly
- This topic has 6 replies, 2 voices, and was last updated 6 years, 5 months ago by April.
-
AuthorPosts
-
November 28, 2017 at 2:17 am #1393512AprilParticipant
I’ve created a shortcode to call the Event Title since most of our Events have the same description and we just want to update Event meta dynamically.
function shortcode_eventtitle() { return tribe_get_events_title($postID); } add_shortcode('eventtitle', 'shortcode_eventtitle');
At first, the shortcode on a list view didn’t appear at all, then I added a filter
add_filter( 'tribe_events_excerpt_allow_shortcode', '__return_true' );
which made the shortcode appear, but instead of getting the Event Name, it’s showing the current page name.
Any ideas to make this work?
November 29, 2017 at 11:53 am #1395175PatriciaMemberHey April,
Thank you for reaching out to us!
Could you please replace tribe_get_events_title() with the_title_attribute() and let me know if it helps you to solve the problem?
Thanks,
Patricia
November 30, 2017 at 5:09 am #1395646AprilParticipantHi Patricia,
that doesn’t solve it I’m afraid. The output is weird now and shortcode is echoed on a places where it shouldn’t be. Please have a look where it echoes and where it’s placed in the backend.
Here are the functions I made for shortcode purposes.
/******************************************************************** Add eventdate shortcode ********************************************************************/ function shortcode_eventdate() { return tribe_get_start_date(null, false, 'F j, Y - g:i a'); } add_shortcode('eventdate', 'shortcode_eventdate'); /******************************************************************** Add eventvenue shortcode ********************************************************************/ function shortcode_eventvenue() { return tribe_get_venue( $postID ); } add_shortcode('eventvenue', 'shortcode_eventvenue'); /******************************************************************** Add eventtitle shortcode ********************************************************************/ function shortcode_eventtitle() { return the_title_attribute(); } add_shortcode('eventtitle', 'shortcode_eventtitle'); /******************************************************************** Add eventcategory shortcode ********************************************************************/ function shortcode_eventcategory() { return tribe_get_event_taxonomy( get_the_id(), array( 'before' => '', 'sep' => ', ', 'after' => '', 'label' => null, // An appropriate plural/singular label will be provided 'label_before' => '<dt>', 'label_after' => '</dt>', 'wrap_before' => '<dd class="tribe-events-event-categories">', 'wrap_after' => '</dd>', ) ); } add_shortcode('eventcategory', 'shortcode_eventcategory'); /******************************************************************** Add eventstarttime shortcode ********************************************************************/ function shortcode_eventstarttime() { return tribe_get_start_date($post, false, $format = 'g:i a' ); } add_shortcode('eventstarttime', 'shortcode_eventstarttime'); /******************************************************************** Add eventendtime shortcode ********************************************************************/ function shortcode_eventendtime() { return tribe_get_end_date($post, false, $format = 'g:i a' ); } add_shortcode('eventendtime', 'shortcode_eventendtime'); add_filter( 'tribe_events_excerpt_allow_shortcode', '__return_true' );
Note that I’ve changed the
the_title_attribute()
per your suggestion. Any other ideas?December 1, 2017 at 11:37 am #1396881PatriciaMemberHi April!
Oh, this is happening because we didn’t set the title attribute for use in PHP. Please replace:
return the_title_attribute();
with:
return the_title_attribute('echo=0');
You will find more info about the_title_attribute here:
https://codex.wordpress.org/Function_Reference/the_title_attribute
I’ve tested the shortcode here and everything is working as expected now š
I hope this helps! If you have any other questions at all please feel free to let me know and Iād be happy to help as best I can!
Cheers,
Patricia
December 8, 2017 at 5:00 am #1401123AprilParticipantWorked! Thanks!
December 8, 2017 at 8:23 am #1401289PatriciaMemberHi April,
You are welcome š I’m glad to hear that everything is working as expected now! If you need an assistance again or have other concerns, please feel free to open up a new thread, we’ll be more than happy to help you!
Cheers,
Patricia
-
AuthorPosts
- The topic ‘Event List is not displaying shortcodes correctly’ is closed to new replies.