Support

Account

Home Forums General Issues Using Relationship Field Not Displaying Content On Other Pages

Unread

Using Relationship Field Not Displaying Content On Other Pages

  • I am using the basic loop with setup_postdata to display a relationship to a custom post type I have. The code is placed in the header.php file and being used to display a featured event post. The issue is not with displaying the code in the header, but when I go to a different page it seems that the_content for any pages do not display. Everything else is fine on the page, but the featured event area does not display either just on the home page. This is what I am using:

    <?php 
     
    $posts = get_field('home_featured_event');
     
    if( $posts ): ?>
        <?php foreach( $posts as $post): ?>
            <?php setup_postdata( $post ); ?>
    
            <a href="<?php the_permalink(); ?>">
                <div class="featured_event floatleft">
                    <div class="floatleft">
                        <?php the_post_thumbnail('wpbs-featured', array( 'class' => "img-responsive attachment-wpbs-featured wp-post-image")); ?>
                    </div>
                    <div class="featured_event_description floatleft">
                        <span class="featured_event_headline">Featured Event</span><br />
                        <span class="featured_event_descriptionbold"><?php the_title(); ?></span><br />
                        <?php the_field('events_location_city-state'); ?><br />
                        <?php the_field('events_start_date'); ?>
                    </div>                                        
                </div>
            </a>                    
        <?php endforeach; wp_reset_postdata(); ?>
    <?php endif; ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.