How to get advance custom post type data

How to get advance custom post type data

 

get image field

$image = get_field('upload_banner_image');
if( !empty( $image ) ): ?>
<img class="product-main-image" src="<?php echo esc_url($image['url']); ?>" class="product-main-image" alt="<?php echo esc_attr($image['alt']); ?>" />
<?php endif; ?>
get other field

<?php 
        $args = array( 
        'post_type' => 'post',
        'posts_per_page' => 4
       );
        $the_query = new WP_Query( $args );
    ?>
    <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <div class="col-sm-6">

            <h2 class="the-title"><?php the_field('field_name', $post->ID); ?> +  <?php the_title() ;?> </h2>


        </div>

    <?php endwhile; else: ?> Nothing here <?php endif; ?>
    <?php wp_reset_query(); ?>

 

 

 

 

 

Leave a Reply