Support

Account

Home Forums General Issues Ability to list custom fields on a "master" page

Solving

Ability to list custom fields on a "master" page

  • Hello. I’m stumped and was wondering if this is possible and if it is, how to go about doing this.

    I have setup three custom fields on my pages, I’ll call them A, B and C. Now, I have ten pages each using these custom fields. What I would like to do is have a “Family” page that will render a table of all of the custom fields like this:

    row 1 A B C
    row 2 A B C
    row 3 A B C
    row 4 A B C

    and so on.

    Thanks for your help!

    David

  • Hi @dparadis

    Do you mean, have a page which loops through all the 10 pages and displays the custom field value?

    Please be a bit more specific. What does ‘row 1 A B C’ mean in your diagram?
    How does this relate to the choice of a page?

  • Elliot,
    Thanks for helping. Here’s a more specific example. If my custom fields are “Product”,”Size”, “Color” and on a given Product page I render:

    Product: Mens’ T-Shirt
    Size: XL
    Color: Blue

    I can do that part no problem. What I’d like to have is a “Master” page that would render a list of all the custom fields from a group of pages like this:

    Product Size Color
    Men’s T-Shirt XL Blue
    Men’s T-Shirt L Blue
    Men’s T-Shirt M Blue
    Men’s T-Shirt XL Red
    Men’s T-Shirt L Red
    Woman’s T-Shirt XL Green
    Woman’s T-Shirt L Green

    I’d then make the list links to their respective pages. All I’ve been able to find so far are repeating (or looping) custom fields on a single page, not grabbing data from other pages to create an aggregate list.

    David

  • Hi @dparadis

    This is possible by querying WP for the posts, then looping through them and rendering the ACF data.

    1. Query WP for a post type (product) – please consult google
    2. Loop through the posts
    3. For each post (product), render the ACF data as per normal.

    Here are some examples which will help:
    * http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/
    * http://www.advancedcustomfields.com/resources/getting-started/code-examples/

    Note: Within your loop, you can use a function called get_the_ID() to get the ID of the current post. Use this value to load the ACF data (second parameter of the_field / get_field)

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

The topic ‘Ability to list custom fields on a "master" page’ is closed to new replies.