Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * The Events Calendar inserts "spoof" posts when the template_include hook fires.
- * We'll hook into that also, but later on, to remove the unnecessary second post.
- */
- add_filter('template_include', 'correctTribePostSpoofing', 50);
- /**
- * Checks if post spoofing has happened and, if so, leaves only one "spoof post"
- * in place.
- *
- * @param $unused (pass-through var)
- * @return mixed ($unused)
- */
- function correctTribePostSpoofing($unused) {
- global $posts;
- // A key indicator that spoofing took place is a post count greater than 1
- if (count($posts) < 2) return $unused;
- // Inspect the first post: does it look like a spoof?
- if ($posts[0]->ID === 1 and empty($posts[0]->guid) and $posts[0]->post_type === TribeEvents::POSTTYPE) {
- // Discard all but the first post
- $posts = array_slice($posts, 0, 1);
- }
- // We don't actually want to change the template selection
- return $unused;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement