{"id":16910182,"date":"2023-07-20T16:33:51","date_gmt":"2023-07-20T16:33:51","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/how-ti-get-values-from-posts-in-archive-loop\/"},"modified":"2023-07-21T12:11:26","modified_gmt":"2023-07-21T12:11:26","slug":"how-ti-get-values-from-posts-in-archive-loop","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/how-ti-get-values-from-posts-in-archive-loop\/","title":{"rendered":"How ti get values from posts in archive loop?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have created shortcode that collects vale from ACF custom field of a post. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It first gets post id using get_the_ID() adn then get_field() to collect custom field value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shortcode works fine in single post template.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<br \/><br \/>I di some debugging and it seems although shortcode is placed in Post Tenlate block within QueryLoop, it&#8217;s code is executed only once on a page, bit value is displayed for each post in loop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am puzzled, how this can be&#8230;<\/p>\n","protected":false},"template":"","class_list":["post-16910182","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16910182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16910182\/revisions"}],"predecessor-version":[{"id":16912428,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16910182\/revisions\/16912428"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16910182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}