• I have a functioning loop for a staff page that is pulling all current staff and displaying them in alphabetical order by last name.

    I need to have a single staff member, the company owner, listed first on the page and then have the loop run to pull the rest of the staff members.

Viewing 2 replies - 1 through 2 (of 2 total)
  • try working with another independant query or with get_post() and exclude this post in your main query;

    possibly useful to read https://codex.ww.wp.xz.cn/The_Loop#Multiple_Loops_in_Action

    Thread Starter hyphenstudio

    (@hyphenstudio)

    Thank you Michael – I thought about multiple loops, but not sure if this will fit my solution as the content displayed needs to be all in rows – I need the owner listed as the first result in row 1 and then the rest of the employees listed out after in multiple rows. Here is what I have currently:

                        <div class="row team-row">
                            <?php add_filter( 'posts_orderby', 'posts_orderby_lastname' );
                                $loop = new WP_Query( array(
                                'post_type' => 'team',
                                'location'  => $location->slug
                                ) );
                            ?>
    
                            <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
                                <div class="col-md-2 team-member">
                                    <?php the_post_thumbnail('medium'); ?>
                                    <h3 class="entry-title"><?php the_title( '' ); ?></h3>
                                    <span class="team-position"><?php the_field('position'); ?></span><br />
                                    <span class="team-phone"><?php the_field('phone'); ?></span><br />
    
                                    <button class="btn btn-small team-btn" data-toggle="modal" data-target="#team-<?php the_ID(); ?>">
                                        View Bio
                                    </button>
    
                                    <div class="modal fade" id="team-<?php the_ID(); ?>" tabindex="-1" role="dialog" aria-labelledby="team-<?php the_ID(); ?>Label" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                                    <h4 class="modal-title" id="team-<?php the_ID(); ?>Label"><?php the_title( '' ); ?></h4>
                                                </div>
                                                <div class="modal-body">
                                                    <div class="entry-content">
                                                        <?php the_content(); ?>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php endwhile; ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Pull A Single Post Prior To Running wp_query’ is closed to new replies.