Hello,
I have implemented the field relationship to post post and custom post on the home.
I have a problem with the image of the custom post.
I would like to take the Image field I entered into the custom management of the custom post I created.
I attach screenshots and part of code hoping that the request is clear.
//single-wine-page:
<?php
$image = get_field('copertina_libro');
$correlata = get_field('copertina_libro_correlata');
$size = 'thumbs-liste'; // (utilizzo la mia dimensione personalizzata)
$sizefull = 'full'; // (utilizzo la dimensione originale)
?>
<div class="row">
<div class="col-md-6">
<div class="img-container">
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute() ?>"><img class="img-responsive" src=<?php echo wp_get_attachment_image( $image, $sizefull );?></a>
</div>
.....
//homepage
<?php
$posts = get_field('correlati_vini');
$image = get_field('copertina_libro');
$correlata = get_field('copertina_libro_correlata');
$size = 'thumbs-liste'; // (utilizzo la mia dimensione personalizzata)
$sizefull = 'full'; // (utilizzo la dimensione originale)
if( $posts ): ?>
<div class="wine-list">
<div class="row row-news ">
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="col-md-4">
<div class="featured-image">
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute() ?>"><img class="img-responsive" src=<?php echo wp_get_attachment_image( $image, $size );?></a>
</div>
.....
if you’re trying to get the images from the related posts then you need to get those fields inside of the loop for those posts
//homepage
<?php
$posts = get_field('correlati_vini');
if( $posts ): ?>
<div class="wine-list">
<div class="row row-news ">
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php
setup_postdata($post);
$image = get_field('copertina_libro');
$correlata = get_field('copertina_libro_correlata');
$size = 'thumbs-liste'; // (utilizzo la mia dimensione personalizzata)
$sizefull = 'full'; // (utilizzo la dimensione originale)
?>
<div class="col-md-4">
<div class="featured-image">
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img class="img-responsive" src="<?php echo wp_get_attachment_image( $image, $size ); ?>" /></a>
</div>
.....
The topic ‘Relationship from a custom post types’ is closed to new replies.
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.