chrislondon on "[Plugin: Theater for WordPress] Display 'today' or 'tomorrow' in event listings"

ساخت وبلاگ

Thanks, Jeroen. I think I'm nearly there, but I've still got two problems.

1. I can't seem to get $event->datetime() to work properly. This is how I used it in my theme functions file: $eventdate = date('Y-m-d',$event->datetime());. It generated this error: 'Call to a member function datetime() on a non-object in [...]functions.php'.

As an experiment, I tried adding the code directly to theatre/functions/wpt_event.php, just to see if I could make it work. This is what I used:

$eventdate = date('Y-m-d',$this->datetime());
$today = date( 'Y-m-d' );

And then I added conditional statements using the two variables to compare dates. It worked fine. But, of course, I want to leave my core files untouched and use the filter to modify the original function in my functions.php file instead. If I simply transfer the code above to my functions.php file, I generate this error: 'Using $this when not in object context in [...]functions.php'.

2. When I made it work by temporarily hacking wpt_event.php, I noticed that filtering $startdate also affected instances where I'd used {{dates}} elsewhere on my site. It looks like $startdate is used to determine $dates in wpt_production.php. I would prefer not to apply the same filter to {{dates}}. To avoid that, could I write a completely new function and create a new filter (for example {{day}}) without hacking the core plugin files?

If not, I'll have to use a conditional statement to restrict the filter to my homepage. Although there are still a couple of instances of {{dates}} on my homepage that would be affected, I think they're ones I could live with.

Any advice would be gratefully received. Thanks for your patience!

Chris

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 323 تاريخ : چهارشنبه 13 مرداد 1395 ساعت: 14:59