display custom fields from all pages on one page (4 posts)

  1. oldbag66
    Posted 6 years ago #

    i have about 15 pages all with about 5 custom fields each using the same, i want to pull all the custom fields into one page as a quick way to read them along witht he page title they are from, would love to be able to crack this but dont know where to start.

  2. ambrosite
    Posted 6 years ago #

    First, set up a custom loop that retrieves all of the pages. Then put this code inside the loop:

    $custom_fields = get_post_custom($post->ID);
    echo '<ul>';
    foreach  ( $custom_fields as $meta_key => $meta_values )
        foreach ( $meta_values as $meta_value )
            echo '<li>' . $meta_key . ": " . $meta_value . "</li>";
    echo '</ul>';

    Note that this will display the WordPress internal custom keys -- such as _edit_last and _edit_lock -- along with the user defined custom keys. If that is a problem, you can try filtering them out using the 'if' test explained on this page:


  3. oldbag66
    Posted 6 years ago #

    thanks but im a little confused how to use it, i did get it working in the loop though, the following is what im trying to achive:

    A page listing all custom fields that exist on other pages

    A single Page with custom fields in right hand panel under the photo:

    And heres the page i want them to display on, currently ive just re-entered the text to recreate the idea but it means updating the avaibility text twice, also it would be good if the artists title was alos pulled in from the page the custom feild is from..


    Hope that makes sense, not easy to explain!


  4. oldbag66
    Posted 6 years ago #

    i was imaging some sort of "list pages" tag that also pulls in the listed pages featured image

Topic Closed

This topic has been closed to new replies.

About this Topic