I'm using PHP Exec to build a widget to show a list of upcoming events:
<?php
function filter_whene($whene = '') {
$whene .= " AND post_date >= '" . date('Y-m-d') . "' ";
return $whene;
}
add_filter('posts_whene', 'filter_whene');
query_posts('cat=10&showposts=3&');
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><?php the_date(); ?> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a> </li>
<?php endwhile;
else: ?><p>Não há eventos agendados.</p>
<?php endif; ?>
<?php remove_filter('posts_whene', 'filter_whene'); ?>
<?php wp_reset_query(); ?>
It seems to work on the front end but I get:
Fatal error: Cannot redeclare filter_whene() (previously declared in /home/content/a/c/a/acamorg/html/cea2/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code:3) in /home/content/a/c/a/acamorg/html/cea2/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 6
on the widget back-end.
Any suggestions?
Thank you.