Support

Account

Home Forums Front-end Issues Cannot see fields on frontend template inside loop

Solving

Cannot see fields on frontend template inside loop

  • I have this custom template with loop and it does not display any acf fields.

    
    <?php
    /*
    Template Name: Custom Ticket View
    */
    ?>
    <?php get_header();?>
    <?php 
    $args = array( 'post_type' => 'ticket', 'posts_per_page' => 20 );
    $the_query = new WP_Query( $args ); 
    ?>
    <?php if ( $the_query->have_posts() ) : ?>
    
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <div class="parent">
    <h2><?php //the_title(); ?></h2>
    <div class="entry-content">
    <div class="ticketno"><?php the_field('category'); ?></div>
    <?php the_content(); ?> 
    </div>
    </div>
    <?php endwhile;
    wp_reset_postdata(); ?>
    <?php else:  ?>
    <?php _e( 'Sorry, no posts matched your criteria.' ); ?>
    
    <?php endif; ?>
     
    <?php get_footer(); ?>
    
  • the_content() will not show fields. You must get/show the values yourself using ACF functions.

    I’d suggest starting here: Getting Started with ACF

  • but I use this code.
    <?php the_field(‘category’); ?>

    it does not show the value as well.

  • what type of field is “category”?

  • That really does not tell me anything, several field types can present as “drop downs”.

    What is the field “type”?

    Also, what is the return value set to?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.