• Resolved Esquivelia

    (@esquivelia)


    Ok so I can get it to work with querying one custom field but when I try two it doesn’t work like I would think it would.

    Here is my code:

    <?php
    	$args = array( 'post_type' => 'ait-dir-item',
    	               'meta_key' => 'location',
    	               'meta_value' => 'Annapolis',
    	               'meta_key' => 'item_tags',
    	               'meta_value' => 'Non-Marine',
    	               'posts_per_page' => 300 );
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    		the_title('<h3 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h3>');
    		echo '<div class="entry-content">';
    		the_content();
    		echo '</div>';
    	endwhile;
    ?>

    Thanks in advance!

    Cory-

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Esquivelia

    (@esquivelia)

    anyone?

    Thread Starter Esquivelia

    (@esquivelia)

    Ok answered my own question.. ??

    <?php
    	$args = array( 'post_type' => 'ait-dir-item',
    	               'meta_query' => array(
    				        array(
    				            'key' => 'location',
    				            'value' => 'annapolis'
    				        ),
    				        array(
    				            'key' => 'item_tags',
    				            'value' => 'non-marine'
    				        )
    				    ),
    				   	'orderby' => 'title',
    					'order' => 'ASC',
    	               'posts_per_page' => 300 );
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    		the_title('<h3 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h3>');
    		echo '<div class="entry-content">';
    		the_content();
    		echo '</div>';
    	endwhile;
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Querying two custom fields in custom post type..’ is closed to new replies.