ACF RELATIONSHIP

ACF関係の表示コードです。add_relationshipがフィールド名です。add_relationshipがフィールド名です。

画像とタイトルを表示しています。投稿オブジェクトです。タームで投稿オブジェクトをソートできます。

<?php $acf_post_objects = get_field('add_relationship'); if( $acf_post_objects ): ?>
	<?php foreach( $acf_post_objects as $post): // ループの開始 ?>
	<?php setup_postdata($post); // 重要! setup_postdata でポストオブジェクトを呼び出します ?>
												
		<article class="works">
			<div class="about-works-icon zoomIn">
				<a href="<?php echo esc_url(get_permalink()); ?>">
					<?php if(has_post_thumbnail()): ?>
                    	<?php the_post_thumbnail('medium_large'); ?>
                	<?php endif; ?>
				</a>
			</div>	
			<a class="detail-link" href="<?php echo esc_url(get_permalink()); ?>">
            	<p class="title"><?php the_title(); ?></p>
              	<p class="news-text">
					<?php
        				$terms = get_the_terms($post->ID, 'demo-cat');
        				if ($terms) :
							foreach ($terms as $term) {
								echo '<span>' . $term->name . '</span>';
							}
						endif;
        			?>
				</p>
			</a>		
        </article>
	<?php endforeach; // ループの終了 ?>
<?php wp_reset_postdata(); // ページの残りの部分は正常に動作するように、ポストオブジェクトをリセットします ?>
<?php endif; ?>

Contact

お問い合わせ
CMS対応のWebサイト作成は、
是非CXG DESIGNへご検討ください。