Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created October 30, 2018 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/16407ed5c86c029127959c7ed8a44c29 to your computer and use it in GitHub Desktop.
Save joshfeck/16407ed5c86c029127959c7ed8a44c29 to your computer and use it in GitHub Desktop.
Tennis club theme fix, add the code starting on line 4 to a child theme's functions.php file, or into a site functions plugin.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
if ( !function_exists( 'tennisclub_query_posts_where' ) ) {
function tennisclub_query_posts_where($where, $query) {
global $wpdb;
if (is_admin() || $query->is_attachment) return $where;
if (tennisclub_strpos($where, 'post_status')===false && (!isset($_REQUEST['preview']) || $_REQUEST['preview']!='true') && (!isset($_REQUEST['vc_editable']) || $_REQUEST['vc_editable']!='true')) {
if (current_user_can('read_private_pages') && current_user_can('read_private_posts'))
$where .= " AND ({$wpdb->posts}.post_status='publish' OR {$wpdb->posts}.post_status='private' OR {$wpdb->posts}.post_status='sold_out')";
else
$where .= " AND ({$wpdb->posts}.post_status='publish' OR {$wpdb->posts}.post_status='sold_out')";
}
return $where;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment