Forum Replies Created
-
AuthorPosts
-
Kyle
MemberThank you. I look forward to the 2.1 release for a little better overall integration.
Kyle
MemberJoachim, thank you for your response but this still does not work. I put in your code (removing the apostrophes and put in the single quotes), then test it and when you search it just redirects the page to the default events page not to the search page with search results.
I have created a SANDBOX to test this in to ensure no other code interferes with this. Fresh WordPress install, using the 2011 theme and I still have this issue. You can see and test the site here – http://henriemediabackup.com/carefreelasvegas/
Kyle
MemberNo worries Jonah! Thank you for your ideas. I look forward to any additional help!
Kyle
MemberSorry, that doesn’t work either. It throws the error “Warning: Missing argument 2 for WP_Query::set()”
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$yesterday_before_midnight = date(‘Y-m-d’, mktime(0, 0, 0, date(‘m’),date(‘d’)-1,date(‘Y’))).’ 23:59:59′;
$meta = array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => $yesterday_before_midnight,
‘compare’ => ‘>’
)
);
$query->set( array( ‘meta_query’=>$meta, ‘post_type’=>’tribe_events’ ) );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );
?>Kyle
MemberSorry, that doesn’t work either. It throws the error “Warning: Missing argument 2 for WP_Query::set()”
Kyle
MemberSorry that is test code. Here is what I have –
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$yesterday_before_midnight = date(‘Y-m-d’, mktime(0, 0, 0, date(‘m’),date(‘d’)-1,date(‘Y’))).’ 23:59:59′;
$meta = array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => $yesterday_before_midnight,
‘compare’ => ‘>’
)
);
$query->set( ‘meta_query’, $meta );
$query->set( ‘post_type’,’tribe_events’ );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );Kyle
MemberI have done this and it doesn’t work it just redirects me to the default events page with the upcoming events listed. Sorry for the hassle. Here is what I have –
function exclude_old_events( $query ) {
if ( $query->is_search && (‘tribe_events’ == get_post_type()) ) {
$yesterday_before_midnight = date(‘Y-m-d’, mktime(0, 0, 0, date(‘m’),date(‘d’)-1,date(‘Y’))).’ 23:59:59′;
$meta = array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => $yesterday_before_midnight,
‘compare’ => ‘>’
)
);
$query->set( ‘meta_query’, $meta );
$query->set( ‘post_type’,’tribe_events’ );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );Kyle
MemberSorry let me be more clear, since I posted my yahoo to soon. If you use this code, only posts that are events or have the meta_key “_EventStartDate” are returned in the results. How do I get this to only apply to event posts instead of all posts?
Kyle
MemberOk one small problem, this code will only posts/pages with the meta_key “_EventStartDate”. How do I get it to only apply posts that are events?
Kyle
MemberOk, I got it to work!!! This is the code to make it happen –
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$yesterday_before_midnight = date(‘Y-m-d’, mktime(0, 0, 0, date(‘m’),date(‘d’)-1,date(‘Y’))).’ 23:59:59′;
$meta = array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => $yesterday_before_midnight,
‘compare’ => ‘>’
)
);
$query->set( ‘meta_query’, $meta );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );Kyle
MemberI also tried to do it by date with no luck –
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$yesterday_before_midnight = date(“Y-m-d”, mktime(0, 0, 0, date(“m”),date(“d”)-1,date(“Y”))).’ 23:59:59′;
$meta = array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => $yesterday_before_midnight,
‘compare’ => ‘>’
)
);
$query->set( ‘meta_query’, $meta );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );Kyle
MemberJonah, thank you for the response. I added the following with no luck. Did I misunderstand what you posted? Thank you for your help!
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$query->set( ‘eventDisplay’, ‘upcoming’ );
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );Nothing happens with this one.
function exclude_old_events( $query ) {
if ( $query->is_search ) {
$query->set(‘eventDisplay’=>’upcoming’);
}
}
add_action( ‘pre_get_posts’, ‘exclude_old_events’ );I get this error: “Parse error: syntax error, unexpected T_DOUBLE_ARROW”
December 22, 2011 at 8:59 pm in reply to: Grid calendar showing last month instead of current month in the drop-down #12639Kyle
MemberI had to revert back to the 1.3 version due to complaints from my website users. I guess I am going to have to build a sandbox environment to work out all of the bugs. You can close the case if you would like.
December 22, 2011 at 8:57 am in reply to: Grid calendar showing last month instead of current month in the drop-down #12634Kyle
MemberI also tried this fix just in case (no luck) – https://theeventscalendar.com/patch-for-the-events-calendar-2-0-2-date-bug/
December 22, 2011 at 8:55 am in reply to: Grid calendar showing last month instead of current month in the drop-down #12632Kyle
MemberRob, thank your for the quick response. I am running both versions as 2.0.2. What is really bizarre is if I change the theme to the TwentyEleven 1.3 theme the date shows up correctly. I have checked my current theme and see no code in the page that is any different than that theme. Any ideas what could possibly make this happen? I am using the default code for the plug-in so all of the calls and functions are standard – no mods whatsoever. So it doesn’t make sense to me. Any help would be appreciated! Thanks again!
-
AuthorPosts
