I'm using a custom loop to show a selection of products. The loop works fine and shows the products with the correct title, image and the other stuff. But the permalink is the URL of the current page.
If I add $post inside the permalink, everything works fine: get_permalink($post)
Here's my current code:
<?php $featured_posts = $products_select; if( $products_select ): ?>
<div>
<ul>
<?php foreach( $featured_posts as $post ): setup_postdata($post); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
</div>
I checked the content of $products_select and saw, that there is no link stored.
Could that be the problem? Is there any way to correct the permalink?
The variable $products_select is the output of a custom field based on relationship field from Advanced Custom Fields. It is stored as post object.