add content before event information
-
Hi,
on the event information page how can I have my own content to display before the event information.
I tried adding the info on the editor, but it displays after the event, whereas I’d like to have it between the title, and the date/time.Thank you
-
try under Events > Settings > Formatting > Events
Thank you.
I did so, but it doesn’t seem to work, unless I missed something.Can you share a link to the page?
Sorry for the delay.
Here is the link, in red the content i’d like to have before the details:
I had modified the event formatting like the following code, and would like to have the extra content to be in the extra-content div.
<div class="row"> <div class="col grid_12_of_12 extra-content"> </div> </div> <div class="row"> <div class="col grid_8_of_12"> <p> <strong>Date/Time</strong><br/> Date(s) - #_EVENTDATES<br /><i>#_EVENTTIMES</i> </p> {has_location} <p> <strong>Location</strong><br/> #_LOCATIONLINK </p> {/has_location} <p> <strong>Category(ies)</strong> #_CATEGORIES </p> <br style="clear:both" /> #_EVENTNOTES {has_bookings} <h3>Bookings</h3> #_BOOKINGFORM {/has_bookings} </div> <div class="col grid_4_of_12"> #_LOCATIONMAP </div> </div>is that using Events > Settings > Formatting > Events > Default single event format ? Or can you try to add the additional content just below this line
<div class="col grid_12_of_12 extra-content">?Thanks for the reply.
Yes that code is put in
Events > Settings > Formatting > Events > Default single event formatI know I can add that info in the extra-content div, problem is that the content is not the same for all events, and each event has its own extra-content.
The example in the given link has been added by just putting it in the wordpress editor, where you usuallly put the content of your page/post, and obviously events-manager is set up to push that content after its (events-manager) own content.
I’d like to change that to first display the wordpress editor content, and only after the events-manager content.
Hiya,
In order to do that you should use the the_content filter in some custom code to add the content before the EM content.
Thanks
Thank you.
Yes, problem is I don’t know how, where, which.
This should help:
https://codex.wordpress.org/Plugin_API/Filter_Reference/the_contentThe Post Icon example is somewhat similar to what you want to do.
Thank you.
I’ve read it, but still can’t figure out where, and how to change it.
I found the_content in em-events.php, and in classes/em-event-post.php but due to my lack of knowledge I just can’t figure it out.
Will you please kindly give me the snip, and where to put it?Try something like this in the functions.php file of your theme:
add_filter( 'the_content', 'my_the_content_filter', 20 ); function my_the_content_filter( $content ) { if ( get_post_type() == 'event') { $before_content = 'your stuff here'; $after_content = 'your 2 stuff here'; $content = $before_content . $content . $after_content; } return $content; }You’d need to fill the $before_content and $after_content variables with your content.
Thank you for your patience.
Unfortunatelly I don’t seem to get it work:
I used your suggestion as it is, and also tried
$before_content = the_content();
$before_content = the_post();In no case I could get the content I put in the editor to show where I need it.
I’m not sure what you’re trying to do with this
$before_content = the_content(); $before_content = the_post();but neither the_content() or the_post() are designed to be used within a function.
I tested the snippet using the default WordPress theme, so I’m not sure why it’s not working in your theme.
Just to clarify, this snippet should output like this on the page:
your stuff here
[events manager output]
your 2 stuff hereIt’ll only work on the single event pages.
Thank you.
Indeed your suggestion was very clear, but since it did not work with my theme (quark), in my ignorance I tried different stuff among which what I posted.
However, even if I get it to work (I’ll try with default WP theme, my intent was to add custom content to each single event, whereas if I am understanding correctly your suggestion it adds the same content for all events.
That’s true, it would. But if you replaced the ‘your stuff here’ parts of the function with, for example, a custom post field you could add unique content to each event.
The topic ‘add content before event information’ is closed to new replies.