terrenceh14
Forum Replies Created
-
Thanks Phil, that’s exactly what I was after.
I used pre_get_posts to add a filter which reset the where clause to select the correct posts based on the _end_ts meta value.
Cheers
I’m not clear on the point made by @marcus.
On my install, if I add an event it’s also added into wp_posts, the post_date of which is the publish date, rather than the event date. The event date is saved in the wp_postmeta table.
The problem here is that when the WP archive queries the database, it pulls back all posts with a post_date matching the selected year, which is when the event (post) was published rather than event date.
I tried adding the filter below without any luck. Reading that post it looks like this code is related to the presentation of the event date, rather than the actual query.
remove_filter(‘the_date’,array(‘EM_Event_Post’,’the_date’));Thanks
Yes, that’s correct.
It looks like the query checks the post_date (which won’t necessarily be the same as event date) and uses that to determine if it should appear. Here’s the query that appears on /post-type/events/2013/.
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id )
WHERE 1 =1
AND YEAR( wp_posts.post_date ) = ‘2013’
AND wp_posts.post_type = ‘event’
AND (
wp_posts.post_status = ‘publish’
OR wp_posts.post_status = ‘private’
)
AND (
wp_postmeta.meta_key = ‘_start_ts’
AND (
mt1.meta_key = ‘_end_ts’
AND CAST( mt1.meta_value AS CHAR ) < ‘1376524800’
)
)
GROUP BY wp_posts.ID
ORDER BY wp_postmeta.meta_value +0 DESC
LIMIT 0 , 10