Home › Forums › General Issues › Notice: Trying to get property of non-object Relationship field › Reply To: Notice: Trying to get property of non-object Relationship field
Sure this is my templates’s Code.
Thanks for taking the time to look at this.
<div class="content__home content_page">
<div class="header__slider flexslider">
<ul class="slides">
<?php if(get_field('home_page_carousel_rep')): ?>
<?php while(has_sub_field('home_page_carousel_rep')): ?>
<li>
<?php if(get_sub_field('home_page_carousel_link')): ?>
<a href="<?php echo get_sub_field('home_page_carousel_link'); ?>">
<?php endif; ?>
<?php if(get_sub_field('home_page_carousel_image')): ?>
<?php $image = get_sub_field('home_page_carousel_image'); ?>
<img src="<?php echo $image['url'] ; ?>" alt="<?php echo $image['alt'] ; ?>" title="<?php echo $image['title'] ; ?>" />
<?php endif; ?>
<?php if(get_sub_field('home_page_carousel_link')): ?>
</a>
<?php endif; ?>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<div class="internal__pages grid">
<?php
$page_chooser = get_field('home_page_chooser_rep');
if( $page_chooser ):
foreach( $page_chooser as $post): ?><?php setup_postdata($post); ?><div class="internal__pages__item grid__item one-quarter">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?></a>
</div><!--
--><?php endforeach; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
</div>
<hr />
<div class="grid two__col">
<?php
$home_page_quick_links = get_field('home_page_quick_links');
if( $home_page_quick_links ):
foreach( $home_page_quick_links as $post): ?><?php setup_postdata($post); ?><div class="grid__item one-half palm-one-whole">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?></a>
<h2 class="single__title"><?php the_title(); ?></h2>
</div><!--
--><?php endforeach; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
</div>
<hr />
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
<?php endwhile; ?>
</div>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.