Home Trying to loop advanced custom fields pro functions .php
Reply: 0

Trying to loop advanced custom fields pro functions .php

user1673
1#
user1673 Published in April 20, 2018, 10:45 am

I am using Advanced Custom Fields with wordpress but I am having an issue getting it to work with creating a short code. I want to drive my team-member post type with a short code that I Can add into visual composer but I am getting an error this is what I have tried.

function team(){ 


   // get posts
   $posts = get_posts(array(
    'post_type'         => 'team-member'

   ));


     if( $posts ): ?>
<?php foreach( $posts as $post ): 
   setup_postdata( $post );       

  $description = get_field('description');
  $name = get_field('name');  

  ' i want to loop here to print out every team member 

    $cnt='';
    $cnt.='<sction class="row ev-home-4">';
        $cnt.='<div class="col-sm-12 owl-carousel owl-theme" id="teams">';
            $cnt.=' <div class="item ev-home-4-block">
                        <div class="col-sm-12 ev-home-4-block-1">
                            <img src="'.get_site_url().'/wp-content/uploads/2017/11/test-1.png" class="img-responsive">
                            <div class="row row2 ev-home-4-block-2">
                                <h2>'.$name.'</h2>
                                <small>'.$description.'</small>
                            </div>
                        </div>
                    </div>';




        $cnt.='</div>';
    $cnt.='</sction>';

    <?php endif; ?>
<?php endforeach; ?>
    return $cnt;
}
add_shortcode('team','team');

But I am getting the following error

https://preview.ibb.co/iJsi5G/chrome_2017_12_07_22_37_54.png

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306325 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO