I have managed to integrate a custom taxonomies plugin that:
-Filters down the staff depending on what category is selected.
I want it to show that department first, and then the other departments beneath rather than that department all on its own (how it is now).
Here is the link: http://crippslawtest.co.uk/people/
I am guessing I need to add a second part to my loop, that says "And display all posts from all other categories afterwards".
Here is my Wordpress loop:
<div class="staffwrapper">
<?php
$args = array( 'post_type' => 'cripps_staff', 'posts_per_page' => 300 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="col-md-3 spacetop">';
echo '<a href="'.get_permalink().'">';
echo '<img src="';
echo get_post_meta($post->ID,'image',true);
echo '">';
echo '</a>';
echo '<h2 class="staffname">';
echo get_post_meta($post->ID,'staff_name',true);
echo '</h2>';
echo '<h2 class="staffrole">';
echo get_post_meta($post->ID,'staff_role',true);
echo '</h2>';
echo '<h2 class="staffnumber">';
echo get_post_meta($post->ID,'staff_telephone_number',true);
echo '</h2>';
echo '<h2 class="staffemail">';
echo get_post_meta($post->ID,'staff_email_address',true);
echo '</h2>';
echo '</div>';
endwhile;
?>
</div><!--End of staff wrapper-->
I have tried to make a 2nd query within my loop with the help of this page: http://codex.wordpress.org/Class_Reference/WP_Query#Methods_and_Properties
What I can't figure out is how to write the argument that pulls "All other posts", any ideas?
Here is my attempt:
<?php
$args = array( 'post_type' => 'cripps_staff', 'posts_per_page' => 300 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="col-md-3 spacetop">';
echo '<a href="'.get_permalink().'">';
echo '<img src="';
echo get_post_meta($post->ID,'image',true);
echo '">';
echo '</a>';
echo '<h2 class="staffname">';
echo get_post_meta($post->ID,'staff_name',true);
echo '</h2>';
echo '<h2 class="staffrole">';
echo get_post_meta($post->ID,'staff_role',true);
echo '</h2>';
echo '<h2 class="staffnumber">';
echo get_post_meta($post->ID,'staff_telephone_number',true);
echo '</h2>';
echo '<h2 class="staffemail">';
echo get_post_meta($post->ID,'staff_email_address',true);
echo '</h2>';
echo '</div>';
endwhile;
// 2nd loop
wp_reset_postdata();
/* The 2nd Query (without global var) */
$query2 = new WP_Query( $args2 );
// The 2nd Loop
while( $query2->have_posts() ) {
$query2->next_post();
echo '<div class="col-md-3 spacetop">';
echo '<a href="'.get_permalink().'">';
echo '<img src="';
echo get_post_meta($post->ID,'image',true);
echo '">';
echo '</a>';
echo '<h2 class="staffname">';
echo get_post_meta($post->ID,'staff_name',true);
echo '</h2>';
echo '<h2 class="staffrole">';
echo get_post_meta($post->ID,'staff_role',true);
echo '</h2>';
echo '<h2 class="staffnumber">';
echo get_post_meta($post->ID,'staff_telephone_number',true);
echo '</h2>';
echo '<h2 class="staffemail">';
echo get_post_meta($post->ID,'staff_email_address',true);
echo '</h2>';
echo '</div>';
// Restore original Post Data
wp_reset_postdata();
}
?>
Thank you!
$args2
. – cybmeta May 1 '14 at 10:51