Sarah

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • Sarah
    Participant

    Great glad we are getting somewhere! Unfortunately we really do need the events to be grouped, since we have some like this which just totally dominate the list, otherwise.

    Can you think of any other workaround? Like to have that grouping occur ONLY on tribe_events post types? (that is how this really should be operating anyway) Perhaps there is some way we could turn off the global grouping setting and instead write it into our query manually so that it only affects events? (not sure how we’d write that, but in theory it seems like that should be possible)
    Thanks a lot for your help!

    Sarah
    Participant

    Sure, here is the var_dump of blogquery… I am wondering if there is a clue in the last couple of lines, where it says “group by” — this query changes based on the settings of the “Show First Instance” box.

    CHECKED:

    string(1116) "
    			SELECT
    				SQL_CALC_FOUND_ROWS *
    			FROM (
    				SELECT  DISTINCT whc2_posts.*, IF (whc2_posts.post_type = 'tribe_events', tribe_event_postmeta.meta_value, whc2_posts.post_date) AS EventStartDate FROM whc2_posts  LEFT JOIN whc2_term_relationships ON (whc2_posts.ID = whc2_term_relationships.object_id) LEFT JOIN whc2_postmeta ON ( whc2_posts.ID = whc2_postmeta.post_id )  LEFT JOIN whc2_postmeta AS mt1 ON (whc2_posts.ID = mt1.post_id AND mt1.meta_key = '_EventStartDate' ) LEFT JOIN whc2_postmeta as tribe_event_postmeta on whc2_posts.ID = tribe_event_postmeta.post_id AND tribe_event_postmeta.meta_key = '_EventStartDate' WHERE 1=1  AND ( 
      whc2_term_relationships.term_taxonomy_id IN (19)
    ) AND ( 
      ( whc2_postmeta.meta_key = '_EventStartDate' AND whc2_postmeta.meta_value > '2017-06-15 21:02:45' ) 
      OR 
      mt1.post_id IS NULL
    ) AND whc2_posts.post_type IN ('post', 'page', 'volunteer_opp', 'tribe_events', 'class', 'support_group') AND ((whc2_posts.post_status = 'publish')) ORDER BY post_date DESC 
    			) a
    			GROUP BY IF( post_parent = 0, ID, post_parent )
    			ORDER BY EventStartDate DESC
    			LIMIT 0, 15
    		"


    UN-CHECKED:

    string(1005) "SELECT SQL_CALC_FOUND_ROWS DISTINCT whc2_posts.*, IF (whc2_posts.post_type = 'tribe_events', tribe_event_postmeta.meta_value, whc2_posts.post_date) AS post_date FROM whc2_posts  LEFT JOIN whc2_term_relationships ON (whc2_posts.ID = whc2_term_relationships.object_id) LEFT JOIN whc2_postmeta ON ( whc2_posts.ID = whc2_postmeta.post_id )  LEFT JOIN whc2_postmeta AS mt1 ON (whc2_posts.ID = mt1.post_id AND mt1.meta_key = '_EventStartDate' ) LEFT JOIN whc2_postmeta as tribe_event_postmeta on whc2_posts.ID = tribe_event_postmeta.post_id AND tribe_event_postmeta.meta_key = '_EventStartDate' WHERE 1=1  AND ( 
      whc2_term_relationships.term_taxonomy_id IN (19)
    ) AND ( 
      ( whc2_postmeta.meta_key = '_EventStartDate' AND whc2_postmeta.meta_value > '2017-06-15 21:05:56' ) 
      OR 
      mt1.post_id IS NULL
    ) AND whc2_posts.post_type IN ('post', 'page', 'volunteer_opp', 'tribe_events', 'class', 'support_group') AND ((whc2_posts.post_status = 'publish')) GROUP BY whc2_posts.ID ORDER BY post_date DESC LIMIT 0, 15"
    Sarah
    Participant

    Hi Victor, thanks for your reply. The SLB plugin still works even when this database error is being reported.

    But I am not sure if this is really a SLB error since it is very definitely referring to Event Calendar settings. My suspicion was that SLB was acting more like a “canary in the coal mine” — ie, revealing an existing problem rather than causing it.

    Sarah
    Participant

    Hi Barry thanks so much for your reply, I’ll be happy to give more detail.

    An example of the page that we are talking about is here: http://whtest2.wizzywigwebdesign.com/ministry/education-discipleship/ (others can be found by going to http://whtest2.wizzywigwebdesign.com/get-involved/whc-ministries/ and selecting any ministry)

    This is a taxonomy archive for a custom taxonomy called “Ministry”. This taxonomy can be applied to multiple post types, including posts, pages, tribe_events, a CPT called “support_groups” and a CPT called “volunteer_opps” and one called “classes”.

    If you go to the archive for this term: http://whtest2.wizzywigwebdesign.com/ministry/care/ and look at the pages that appear, then if you tick the “page” box to filter just pages, you’ll see there are actually many more pages than are being displayed here. When the box is not checked (ie should be showing ALL post types incl. pages) it only shows the ONE most recent child page (of a parent page called “Find Support”).

    We have a custom theme and the template used on this page is using ajax to populate the page (based on the selected post types that the user has chosen to filter for). The taxonomy-ministry.php theme file itself is pretty vanilla, nothing fancy, other than some checkboxes to allow users to filter post type:

    Filter by:

    <div id=”ministry_filters”>
    <label><input type=”checkbox” name=”volunteer_opp”> Volunteer Opportunities</label>
    <label><input type=”checkbox” name=”page”> Pages</label>
    <label><input type=”checkbox” name=”post”> Posts</label>
    <label><input type=”checkbox” name=”tribe_events”> Events</label>
    <label><input type=”checkbox” name=”class”> Classes</label>
    <label><input type=”checkbox” name=”support_group”> Support Groups</label>
    </div>

    The custom code comes in via the following script in our functions.php file.

    (Note that this issue overlaps an issue regarding a database error when the “show only first instance” is checked, which is still awaiting support in this thread.)

    // ---------------- Filter Ministries ------------------
    add_action( 'wp_ajax_filter_ministry', 'filter_ministry' );
    add_action( 'wp_ajax_nopriv_filter_ministry', 'filter_ministry' );
    
    function filter_ministry(){
        global $wpdb; // access to the database
    
        $paged = ( isset($_REQUEST['paged'] ) ) ? $_REQUEST['paged'] : 1;
    
        $args = array(
            'posts_per_page'         => '15',
            'paged' => $paged,
            'post_status' => 'publish',
        );
    
        if (isset($_REQUEST['post_type']) and !empty($_REQUEST['post_type'])){
            $args['post_type'] = array_keys($_REQUEST['post_type']);
        }
        else{
            $args['post_type'] = array('post','page','volunteer_opp','tribe_events','class','support_group');
        }
        #$args['tax_query'] = array();
        $args['tax_query'] = array(
                array(
            'taxonomy'  => 'ministry',
            'field'   => 'slug',
            'terms'   => array($_REQUEST['term']),
            'operator' => 'IN'
            )
        );
    
        if (count($args['post_type'])>1 and in_array('tribe_events',$args['post_type'])){
            $args['meta_query'] = array(
                    'relation' => 'OR',
                    'end_date_clause' => array(
                            'key' => '_EventStartDate',
                            'value' => date("Y-m-d H:i:s"),
                            'compare' => '>'
                    ),
                    'date_exist_clause' => array(
                            'key' => '_EventStartDate',
                            'compare' => 'NOT EXISTS'
                    )
            );
        }
    
        $blogquery = new WP_Query( $args );
    
        ob_start();
        // The Loop
        if ( $blogquery->have_posts() ) {
            while ( $blogquery->have_posts() ) {
                $blogquery->the_post();
                if(get_post_type() != "staff_member") { // we don't display staff members in this list ?>
                    <article class="excerpt clearfix">
                        
                        <h2><a>"><?php the_title(); ?></a></h2>
    
                        <h4>
    	                    <?php 
    	                    $mytype = get_post_type();
    	                    $obj=get_post_type_object($mytype);
    						echo $obj->labels->singular_name;
    						?>
                        <?php if(get_post_type() != 'tribe_events') { //just show the post date for posts
    	                    		if(get_post_type() == 'post') { ?>
    	                    			  &bull; <?php wizzy_wig_posted_on(); ?>
    		                    	<?php } ?>
    		                    
    		                <?php } else { // show the event date if it's an event
    			                if (function_exists('tribe_get_start_date')) {
    		                    	echo ' &bull; ' . tribe_get_start_date() ;
    		                    }
    		                }
    	                ?>
    	                </h4>   
                        
                        <?php the_excerpt(); ?>
                        <hr />
                    </article>
        <?php } ?>
            <?php }
        }
        else{
            echo '<h1>Nothing found</h1>';
        }
    
        matword_pagination2($blogquery);
    
        $res = ob_get_contents();
        ob_end_clean();
        echo $res;
        exit;
    }
    
    // ---------------- The pagination script referenced in the function above ------------------
    function matword_pagination2($blogquery) {
    
        $prev_arrow = is_rtl() ? '&rarr;' : '&larr;';
        $next_arrow = is_rtl() ? '&larr;' : '&rarr;';
    
        $total = $blogquery->max_num_pages;
        $big = 999999999; // need an unlikely integer
        if( $total > 1 )  {
             if( !$current_page = $_REQUEST['paged'] )
                 $current_page = 1;
             if( get_option('permalink_structure') ) {
                 $format = 'page/%#%/';
             } else {
                 $format = "&paged=%#%";
             }
            echo paginate_links(array(
                'base'          => htmlspecialchars_decode(  str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ) ),
                'format'        => $format,
                'current'       => max( 1, $_REQUEST['paged'] ),
                'total'         => $total,
                'mid_size'      => 3,
                'type'          => 'list',
                'prev_text'     => $prev_arrow,
                'next_text'     => $next_arrow,
             ) );
        }
    }
    Sarah
    Participant

    Additional info:
    This error also ONLY occurs when “Show only the first instance of each recurring event” is checked in The Events Calendar settings.

    So again, steps to repeat (at least on our system):
    – create a recurring event
    – check box for “Show only the first instance of each recurring event” in Events Calendar settings
    – make sure Simple LightBox is enabled.
    – view a single instance of a recurring event (on the front end).

    If you have Query Monitory installed, you can see the error and get details.

Viewing 5 posts - 1 through 5 (of 5 total)