[EventCalendar] re: Showing the event post ONLY on the day it
occurs
Alex Tingle
alex at firetree.net
Mon Dec 4 18:13:37 UTC 2006
Dave,
That's an excellent plug-in. Less is more! May I make one suggestion? Increase the priority of the filter, so this gets run earlier than other plug-ins:
add_filter('posts_where', 'wp_future_posts_plugin',1);
-Alex
--
On Mon, 4 Dec 2006 12:54:30 -0500
Dave Warker <davew1 at mac.com> wrote:
> > How do you make EventCalendar display the post corresponding to an
> > event ONLY on the day it occurs, but otherwise hide it from view on
> > the front page?
>
> Hi Alessandro. I've run into the same problem. In theory you can
> enter a future post date, the day of your event, and it will not
> appear until that date. However, by default Wordpress won't display
> future dated posts to anonymous (non logged-in) users so when they
> click on a link to see a future dated event they instead get a "no
> matching item" message. Previously there was a hack to Wordpress to
> work around this but Alex has (rightly) decided its a Wordpress issue
> and should be dealt with as such.
>
> There is a simple plug-in called Future Posts:
>
> http://www.figby.com/archives/2005/04/12/wordpress-15-plug-in-view-
> future-posts/
>
> that is supposed to fix this exact issue but so far I haven't been
> able to get it to work, at least on the latest Wordpress version on
> my site. There are hints on fixes it in the comments on that page but
> even after correcting for mangling of the posted code it still isn't
> working.
>
> It operates by adding a filter to the SQL commands used to fetch
> entries that removes the clause that specifically checks that the
> post date is <= the current time. I've verified my modified and
> simplified version of the plug-in is in fact doing that, but the
> posts still don't appear for anonymous users.
>
> Here is my test plug-in (between the // ----- comment lines.) The
> original version had several options but for testing I've hard-coded
> it to assume what I want: show future posts when they are viewed as a
> single item. It is saved as futureposts.php, placed in the plug-ins
> folder and activated:
>
> // ----- futureposts.php:
> <?php
>
> function wp_future_posts_plugin($content)
> {
> if (is_single())
> $content = preg_replace("/ AND post_date_gmt <= \'.+\'/", "",
> $content);
> return $content;
> }
>
> add_filter('posts_where', 'wp_future_posts_plugin');
>
> ?>
> // -----
>
> Not a whole lot to it. The preg_replace line is the key, it matches
> the portion of the command that excludes future posts and replaces it
> with an empty string. Maybe someone else better versed in Wordpress
> SQL usage can see the problem.
>
> This is NOT the official futureposts plug-in code so please don't
> distribute it as such. When there is a working fix it should be
> submitted to the original author so he can incorporate it.
>
> Dave Warker <davew1 at mac.com>
>
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar
--
:: Let me solve your problems: http://www.firetree.net/consulting/
:: alex.tingle AT firetree.net +44-7901-552763
More information about the EventCalendar
mailing list