L
L
LastGeneral2021-12-28 16:26:09
WordPress
LastGeneral, 2021-12-28 16:26:09

How to use Advanced Custom Fields to display posts of a certain category on the product page?

I want to implement, on the page, the ability to display records of the category recipes, I use ACF

<?php $recipes = get_field( 'recipes' ); ?>
<?php if ( $recipes ) : ?>
  <?php foreach ( $recipes as $post ) : ?>
    <?php setup_postdata ( $post ); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  <?php endforeach; ?>
  <?php wp_reset_postdata(); ?>
<?php endif; ?>

But the name of the product and a link to it are displayed, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-12-28
@pro100taa

Why such difficulties. Output through a regular loop https://wp-kama.ru/function/query_posts#categories

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question