• Hello,

    I’m running into an issue where, when using checkboxes to select taxonomies and submitting the form – I am getting ALL posts in my CPT

    Here is an example, http://waters.imagebox.com/?qmt%5Bsubjects%5D%5B%5D=23&qmt%5Bgrades%5D%5B%5D=31&qmt%5Bhabits%5D%5B%5D=53&qmt%5Btools%5D%5B%5D=64&qmt%5Bresource-types%5D%5B%5D=65

    I’m using the following query to get my CPT’s post to display:

    <?php
    				global $post;
    				$args = array( 'numberposts' => -1, 'post_type' => 'resources' );
    				$myposts = get_posts( $args );
    				foreach( $myposts as $post ) :	setup_postdata($post); ?>
    
    					<tr>
    						<td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>
    						<td>
    							<?php
    
    								$terms = get_the_terms(get_the_ID(), 'subjects');
    								$subjects = array();
    								foreach ($terms as $term) {
    									if ($term->term_id != 69) $subjects[] = $term->name;
    								}
    								echo '' . implode(', ', $subjects);
    							?>
    						</td>
    						<td>
    							<?php
    
    								$terms2 = get_the_terms(get_the_ID(), 'grades');
    								$grades = array();
    								foreach ($terms2 as $term) {
    									if ($term->term_id != 70) $grades[] = $term->name;
    								}
    								echo '' . implode(', ', $grades);
    							?>
    						</td>
    						<td>
    							<?php
    
    								$terms3 = get_the_terms(get_the_ID(), 'habits');
    								$habits = array();
    								foreach ($terms3 as $term) {
    									if ($term->term_id != 71) $habits[] = $term->name;
    								}
    								echo '' . implode(', ', $habits);
    							?>
    						</td>
    						<td>
    							<?php
    
    								$terms4 = get_the_terms(get_the_ID(), 'tools');
    								$tools = array();
    								foreach ($terms4 as $term) {
    									if ($term->term_id != 72) $tools[] = $term->name;
    								}
    								echo '' . implode(', ', $tools);
    							?>
    						</td>
    						<td>
    							<?php
    
    								$terms5 = get_the_terms(get_the_ID(), 'resource-types');
    								$resource_types = array();
    								foreach ($terms5 as $term) {
    									if ($term->term_id != 74) $resource_types[] = $term->name;
    								}
    								echo '' . implode(', ', $resource_types);
    							?>
    						</td>
    					</tr>
    
    				<?php endforeach; ?>
    
    					</tbody>
    				</table>

    Is there something wrong with my query that is causing all posts to display instead of the ones I am trying to filter?

    Thanks!

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

Viewing 1 replies (of 1 total)
  • The problem is you’re overriding the standard wp_query with your own custom-query called $myposts.
    Unfortunately I’m trying to do the same at the moment, with no luck. But I guess the way to go is to extend or decrease the standard wp_query with something like the $query_string;

Viewing 1 replies (of 1 total)
  • The topic ‘Proper Custom post type query for use with plugin’ is closed to new replies.