0

Ok I am trying to get a custom post type working with a couple of fields for the most part it works and outputs the data but instead of each team member it is display the same team member multiple times.

function team(){


// args
$args = array(
    'numberposts'   => -1,
    'post_type'     => 'team-member'

);


// query
$the_query = new WP_Query( $args );

  if( $the_query->have_posts() ): 

  while( $the_query->have_posts() ) : $the_query->the_post();  
  ?>
        <sction class="row ev-home-4">
        <div class="col-sm-12 owl-carousel owl-theme" id="teams">
        <div class="item ev-home-4-block">



            <a href="<?php the_permalink(); ?>">
                <img src="<?php the_field('photo'); ?>" class="img-responsive" />

                <div class="row row2 ev-home-4-block-2">
                <h2><?php the_title(); ?></h2>
                <small><?php the_field('description'); ?></small>
                </div>
            </a>
                </div>
                        </div>
                        </div>
                        </sction>
    <?php endwhile; ?>
    </ul>
<?php endif; ?>

<?php wp_reset_query();  // Restore global post data stomped by the_post(). 

https://i.stack.imgur.com/gK5Op.jpg

I dont have a rep of ten so dont no how to add an image sorry about that.

Edit 2 Screen shot to show different data.

https://i.stack.imgur.com/pH1Pi.jpg

Screen shot to show differnt photos for data

Teammember 1

https://i.stack.imgur.com/YmT2B.jpg

Team Member 2

https://i.stack.imgur.com/aChN4.jpg

The above is what it should be printing out.

Edit 3 Ok So i have the team members showing fine now but its showing one below another instead of left to right

function team(){


$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$args = array(
  'post_type' => array('team-member'), 
  'post_status' => 'publish', 
  'order' => 'DESC', 
  'orderby' => 'date', 
  'posts_per_page' => 6, 
  'paged' => $paged, 
);



// WP_Query
$eq_query = new WP_Query( $args );
if ($eq_query->have_posts()) : // The Loop
?>

<sction class="row ev-home-4"> 
<?php 

while ($eq_query->have_posts()): $eq_query->the_post();
?>

           <div class="item ev-home-4-block" style="float:left;">
            <img src="<?php the_field('photo'); ?>" class="img-responsive" />

                                <div class="row row2 ev-home-4-block-2">

                                <h2><?php the_field('name'); ?></h2>
                                <small><?php the_field('desciption'); ?></small>
                            </div>

                            </div>




 </div>



<?php endwhile; wp_reset_query(); ?> 

<?php include(EQ_PAGING); ?>

<?php endif;  




    return $cnt;
}
add_shortcode('team','team');

As you see here it is showing it below the other pic when they should be to the right of each other

https://i.stack.imgur.com/b3Yme.jpg

Paulie_D
  • 107,962
  • 13
  • 142
  • 161
rogue1nib
  • 43
  • 1
  • 6
  • Have you **definitely** assigned unique images in the ACF field to each post? And not just set unique images in the 'featured image' part, for example? – ProEvilz Dec 08 '17 at 13:04
  • @ProEvilz Yes I have and content let me show you – rogue1nib Dec 08 '17 at 13:05
  • @ProEvilz please see above edits – rogue1nib Dec 08 '17 at 13:09
  • first of it, it should be `'posts_per_page'=>-1,` not `numberposts` – ProEvilz Dec 08 '17 at 13:18
  • @ProEvilz yes they are not on the featured image ! it wouldnt find that image their anyway ! its a unique field called photo ! – rogue1nib Dec 08 '17 at 13:20
  • Please amend your code with what I wrote above then do a `var_dump($the_query);` and paste the output in your post – ProEvilz Dec 08 '17 at 13:21
  • As you see its not just the photo is getting repeated its the data as well so this is not just a photo issues @ProEvilz – rogue1nib Dec 08 '17 at 13:22
  • It's almost like you're not reading what I'm putting. I know it's a problem with the data. Please follow my steps or I can't help. – ProEvilz Dec 08 '17 at 13:22
  • @ProEvilz why would I want post per page surley i want all showing – rogue1nib Dec 08 '17 at 13:23
  • `numberposts` is not the right way to do it, `posts_per_page` is. The `-1` means show ALL posts... that's why you've got it set to `-1` with `numberposts` to begin with. – ProEvilz Dec 08 '17 at 13:24
  • @ProEvilz Please find the var dump here it is indead getting the two records fine https://pastebin.com/R0yFvi5U but i changed the code and its still outputting the same record 4 times dont get this – rogue1nib Dec 08 '17 at 13:25
  • Hmm yes this is odd. Please dump the post variable it's self too – ProEvilz Dec 08 '17 at 13:36
  • @ProEvilz its something to do with the 4 block for some reason i have it outputting two now but not the way it was – rogue1nib Dec 08 '17 at 13:43
  • @ProEvilz have a look at above edit see if you can tell what going on – rogue1nib Dec 08 '17 at 13:49
  • You have a typo `'sction'` and you shouldn't have to write all that out for this. – ProEvilz Dec 08 '17 at 14:32
  • Post the code for your CPT and export the ACF fields for this CPT with XML format as the choice. I'll go off and create a simpler script and report back – ProEvilz Dec 08 '17 at 14:34

0 Answers0