How ti get values from posts in archive loop?
-
I have created shortcode that collects vale from ACF custom field of a post.
It first gets post id using get_the_ID() adn then get_field() to collect custom field value.
Shortcode works fine in single post template.
However, when used in archive template, instead of collecting value for each post in a loop, it seems collects value form the first post and shows the same value for all posts on a page. If there are more pages, then on each page it gets value of the first post on a page and shows the same value for rest of the posts on page.
I di some debugging and it seems although shortcode is placed in Post Tenlate block within QueryLoop, it’s code is executed only once on a page, bit value is displayed for each post in loop.I am puzzled, how this can be…
- The topic ‘How ti get values from posts in archive loop?’ is closed to new replies.