Support

Account

Home Forums Add-ons Repeater Field Display values from a field used on multiple pages

Helping

Display values from a field used on multiple pages

  • Is it possible to display all values of a field that is used on multiple pages? I’m used a repeater with a text area sub-field to add reviews for the tours my client provides. Each tour page has multiple reviews. What I would like to do in the sidebar of some pages is collect ALL the reviews sitewide and then display one random review on page load.

    Thanks!

  • Using standard WP methods you would need to do a query for every post that might have a review and then loop through the repeater fields on every post to collect them all. If there are a lot this would more than likely time out your site, although you could probably incorporate some type of object or fragment caching. If you do a search you’ll find plenty of information on it.

    You could use #wpdb and query the wp_meta table directly to speed things up https://codex.wordpress.org/Class_Reference/wpdb, but because you’re using repeater fields the query would be quite complicated. If you’re thinking about this you should probably spend some time digging around in the database to see how ACF stores the values of a repeater.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Display values from a field used on multiple pages’ is closed to new replies.