How to display a relationship field in the first paragraph?

I use plugin Advanced Custom Fields to create a relationship field to make related posts.

I want to display the result after the first paragraph in each post. How can I do that? Please help me

This is the code I use to show the result

<?php
$post = get_field(‘relatedpost’);
$field = get_field_object(‘relatedpost’);
?>
<?php if( $post ): ?>
<ul style=”list-style: none;”>
<?php foreach( $post as $post1 ): ?>
<li style=”font-size: 13px; font-weight: bold;”>
<?php echo get_the_date( “d/m/Y”, $post1->ID ).” | “; ?><a href=”<?php echo get_permalink( $post1->ID ); ?>” rel=”noopener nofollow noreferrer”>
<?php echo get_the_title( $post1->ID ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

Read more here:: How to display a relationship field in the first paragraph?

Leave a Reply

Your email address will not be published. Required fields are marked *