if you have images which you want to remove from the output, you may want to add this line
$replace = preg_replace(‘/<img[^>]+./’,”, $replace);
just below
$replace = $this->post_content;
and above
if($result == “#_MYEXCERPT”){
thanks for contributing, but as you very well know, modifying the core plugin is naughty 🙂
given you managed to do this, you might find this useful: http://wp-events-plugin.com/tutorials/modifying-placeholder-default-information/
that way you can override the placeholder without touching our plugin
Marcus, Your absolutely right. I’m going to try and play around with that tomorrow
Thanks for your prompt response
Marcus, would that then be em_eventexcerpt_output_placeholder for the #_EVENTEXCERPT? Can’t find anything about it online and after searching your website I didn’t find anything.
Ah, or em_event_output_placeholder?
i got it folks! i will provide you with my example of how i successfully created the custom placeholder. the example in the links were a bit confusing for me.
here we go, just add the code to your functions.php file. no need to edit the plugin as we all agreed was a bad idea.
//creating a custom placeholder
//create the filter. the website will search for our placeholder using this function
add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3); // change the name of the function from em_event_output_placeholder to em_events_something
function my_em_styles_placeholders($replace, $EM_Event, $result){ //make sure you change the name of the function to em_events_something
global $wp_query, $wp_rewrite;
switch( $result ){
case '#_MYEXCERPT': // name of the placeholder
$replace = $EM_Event->output("#_EVENTNOTES"); //lets retrieve the original event data so we can modify it
$replace = preg_replace('/<img[^>]+./','', $replace); // make the modification of taking out any images
if($result == "#_MYEXCERPT"){ //heres what we are goign to do if the placeholder has been found
$length = 25; //length of word for (the excerpt)
$replace = implode(' ',array_slice(explode(' ', $replace),0,$length)); //apply the length amount to the output
$replace = $replace . '...'; //add 3 periods after lenth has been reached
}
break; // end the case
}
return $replace; //output the placeholder
}
would love to know if this was helpful to someone
looks good, thx for sharing
Thanks for the feedback abd inspiration Marcus!
Fantastic solution, thank you so much! Would have taken me hours to get this sorted without you. Much appreciated, Gavin.
I made a small change to your script, because it was adding the … to the end of the ones that were already short enough or excerpts. I set it to check if the excerpt was already shorter than 25 words, and if so it will leave it alone:
//creating a custom placeholder
//create the filter. the website will search for our placeholder using this function
add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3);
function my_em_styles_placeholders($replace, $EM_Event, $result){
global $wp_query, $wp_rewrite;
switch( $result ){
case '#_MYEXCERPT': // name of the placeholder
$replace = $EM_Event->output("#_EVENTEXCERPT"); //lets retrieve the original event data so we can modify it
$replace = preg_replace('/<img[^>]+./','', $replace); // make the modification of taking out any images
if($result == "#_MYEXCERPT"){ //heres what we are goign to do if the placeholder has been found
if ( str_word_count($replace) > 25 ) {
$length = 25; //length of word for (the excerpt)
$replace = implode(' ',array_slice(explode(' ', $replace),0,$length)); //apply the length amount to the output
$replace = $replace . '... '; //add 3 periods after lenth has been reached
}
}
break; // end the case
}
return $replace; //output the placeholder
}
Glad I Was helpful! Seems like you got the hang of it! Thanks for your additional example! I hope someone else may find it helpful!
Thanks for the excellent code, this is exactly what I was looking for and you saved me a couple of hours. You’re a hero!
like!!! glad i was able to help!
Thanks for sharing the code!
This should replace the excerpt-code used now IMO