Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Event Manager plugin. I want to use many of the shortcodes via php code. e.g [events_calendar]

share|improve this question

2 Answers 2

up vote 1 down vote accepted

In general, you can do any shortcode with do_shortcode() (see codex). But if they have a template function available, its probably best to use that.

 echo do_shortcode('[events_calendar]');
share|improve this answer
    
thanks dude its working and now I can use any shortcode. –  Bhuvnesh Gupta Jan 17 '13 at 12:05
    
now one more problem is there. do_shortcode('[events_calendar]'); this is working fine but I want to use <?php echo do_shortcode('[events_calendar long_events=1]') . it's not working –  Bhuvnesh Gupta Jan 17 '13 at 12:15
    
@Bhuvnesh It should work. You can pass attributes like that with do_shortcode. A bug with the plug-in perhaps? Probably best to ask them on the plug-in forums as there's not much else to add here :). –  Stephen Harris Jan 17 '13 at 14:54
    
Perhaps set the value in double quotes, like '[events_calender long_events="1"]' –  bueltge Jan 17 '13 at 22:48
    
@bueltge I don't think that matters. At least I know [shortcode attribute=true] passes the value of attribute as a string rather than boolean. –  Stephen Harris Jan 22 '13 at 11:09

I think em-template-tags.php may have what you're looking for

EDIT

Per Events Manager's documentation, template tags can be found within the file em-template-tags.php, which is in the root of the plugin directory.

For example, [locations_list $atts] would have the corresponding template tag em_locations(). I just tried this example on a clean WP 3.5 install and the results are the same.

2ND EDIT

Alternatively, you can just call the function to which the shortcode is hooked. em-shortcode.php, also in the plugin root, has all of the shortcodes and corresponding functions in it.

For your example of [events_calendar], <?php echo em_get_calendar_shortcode(); ?> displays the calendar just as the shortcode would.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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