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

put on hold as off-topic by Pieter Goosen, Mayeenul Islam, Mark Kaplun, toscho 7 hours ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers 3

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
1  
@StephenHarris yes, you are right on default. But I had seen not seldom, that plugin developers filter the data a little bid wrong. –  bueltge Jan 23 '13 at 11:49

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

Specific Events Manager template tags are another way to achieve this, for example:

<?php 
echo EM_Events::output(array('scope'=>'tomorrow', 'limit'=>10, ));
?>

You can use any of the attributes. (http://wp-events-plugin.com/documentation/event-search-attributes/)

One of the attributes is, 'format', which formats the output and lets you use html and all the placeholders (http://wp-events-plugin.com/documentation/placeholders/) and conditional tags.

So you can do this:

<?php 
echo EM_Events::output(array('scope'=>'tomorrow', 'limit'=>10, 'format'=>' 

    <div>#_EVENTNAME</div> 
    <div>#_EVENTDATES</div>
{has_location}
    <div>#_LOCATIONNAME</div>
{/has_location}

'));
?>
share|improve this answer

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