Support

Account

Home Forums General Issues New acf entries not showing

Solved

New acf entries not showing

  • Hi there,

    Have updated a site to a new theme and all seemed to be working fine. Have three custom post types, two (awards, publications) include acf relationship field lookup third (project). The reverse lookup from the third (project) working fine for existing items. See awards & publications listed on this page.

    But when I add a new custom post (either award or publications) and set the relationship field to a project they reverse lookup not showing anything. See no awards on this page.

    I know that the Absolutely frustrating!

    The new awards appear on the Awards page and are correctly looking up the featured image and title.

    But no new award entries will appear in a reverse lookup while the old ones will. Needless to say, have flushed cache and checked entry in DB a:1:{i:0;s:4:”2223″;}.

    I believe the code is fine as it’s working for some but not others:

     <?php 
    $awards = get_posts(array(
    'post_type' => 'awards',
    'orderby' => the_field('award_year'),
    'order' => 'DESC',
    'meta_query' => array(
                          array(
                          'key' => 'project',
                           'value' => $post->ID,
                                )
                            )
    			));
    ?>
    <?php if( $awards ): 
    echo '<h3>AWARDS RECEIVED:</h3>';?>
    <?php foreach( $awards as $award ): ?>
    <a href="<?php echo get_permalink( 60); ?>">
    <?php echo get_the_title( $award->ID ); ?>
    </a>
    <?php endforeach; ?>
    <?php endif; ?>
    

    Are there any other ways I can test what’s going on (or not :).

  • A relationship field stores an array of post IDs. Try

    
    'meta_query' => array(
        array(
            'key' => 'project',
            'value' => '"'.$post->ID.'"',
            'compare' => 'LIKE'
        )
    )
    
  • Any idea why I’m having problems with this John?

    I’m getting all data in correctly but I want to change the order displayed. When I put the relationship lookup first, the awards data (award name/year/short description) disappears. I can make it appear this way using absolute positioning but it stuffs up when it comes to other devices.

    !! I will get this relationshi/reverse relationship stuff worked out one day 🙂

    Thx

    This is the order I want but cannot get

    
    <?php $awards_query = new WP_Query( array( 'post_type' => 'awards', 'showposts' => 50, 'meta_key'=>'award_year',  'orderby' => 'meta_value_num' ) ); ?>
    
    <?php while ($awards_query->have_posts()) : $awards_query->the_post(); ?>
    
    <div class="vc_col-med-4 vc_col-lg-4 vc_col-sm-6 vc_col-xs-12 awards"> 
    <?php foreach(get_field('project') as $post):
       setup_postdata($post); ?>
       <a href="<?php the_permalink(); ?>" >
       <?php the_post_thumbnail('awards', array( 'class' => 'award_img' ) ); ?></a>
       <h3 class="award_project"><?php the_title(); ?></h3>
       <?php endforeach; wp_reset_postdata(); ?>
    
      <h2 class="award_name"><?php the_field('award_name'); ?> | 
      <?php the_field('award_year'); ?></h2>
      <p><?php the_field('short_description'); ?></p> 
    
    </div><!--end cols -->
    
    

    This is the work around I’m using with absolute positioning

    
    <?php $awards_query = new WP_Query( array( 'post_type' => 'awards', 'showposts' => 50, 'meta_key'=>'award_year',  'orderby' => 'meta_value_num' ) ); ?>
    
    <?php while ($awards_query->have_posts()) : $awards_query->the_post(); ?>
    
    <div class="vc_col-med-4 vc_col-lg-4 vc_col-sm-6 vc_col-xs-12 awards"> 
      <h2 class="award_name"><?php the_field('award_name'); ?> | 
      <?php the_field('award_year'); ?></h2>
      <p><?php the_field('short_description'); ?></p> 
    
    <?php foreach(get_field('project') as $post):
       setup_postdata($post); ?>
       <a href="<?php the_permalink(); ?>" >
       <?php the_post_thumbnail('awards', array( 'class' => 'award_img' ) ); ?></a>
       <h3 class="award_project"><?php the_title(); ?></h3>
       <?php endforeach; wp_reset_postdata(); ?>
    
    </div><!--end cols -->
    
    
  • The data is being output but hidden somehow?

    If everything is working then I’d start looking at the CSS to figure out why it’s not displaying correctly.

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

The topic ‘New acf entries not showing’ is closed to new replies.