WordPress.org

Ready to get started?Download WordPress

Forums

Listing custom fields on parent page? (4 posts)

  1. halsnalle
    Member
    Posted 8 years ago #

    How do I get the custom fields values of a subpage appear on a parent page?

    Using:

    * WordPress custom fields
    * Get Custom Field Value plugin
    * List Subpages plugin

    ...I'm trying to build an archive for articles I have published in various newspapers. Every article is a subpage of my article archive Page (I'm trying it out at http://www.mothugg.se/texts), which lists all articles. On the individual subpage (an article), I display custom fields for Author (if coauthored), Publication, and Publication Date.

    Works fine. However, it would of course be a more user-friendly archive if I could display not only the title of each article on the Page, but also Publication and Publication Date. Like so:

    * "Title of the article", in The Newspaper 2006-12-31.

    ...either as a u-list or as a table.

    Ehm, since all the data is in the database, it shouldn't be impossible, right?

  2. Dgold
    Member
    Posted 8 years ago #

    Yes it's possible. I use the Get Custom Fields plugin on an archive page. I made custom Archive template. You can use your Archive template or make a new one and select it for your special archive under Admin > Write > Page.

    I use some code like this, (in the template, not in the Write Page)

    <?php query_posts('orderby=title&order=asc&showposts=-1'); ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <li><?php echo c2c_get_custom('Your Custom Field Name'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permalink for <?php the_title(); ?>"><?php the_title(); ?></a> </li>
    <?php endwhile; ?>

    <?php endif; ?>

  3. halsnalle
    Member
    Posted 8 years ago #

    Thanks, Dgold, but it doesn't work for me. I only get a list of all my Posts (all 500+ of them...), but not of the Subpages of the Page to which I have applied the template.

    Is there someway to tell query_posts only to list subpages of the current page? If so, I think your solution might actually work for what I have in mind.

  4. Younghusband
    Member
    Posted 8 years ago #

    Dgold, can you take a look at this post, please: List posts by Key

Topic Closed

This topic has been closed to new replies.

About this Topic