Grow your CSS skills. Land your dream job.

WordPress Custom Fields from Sub-Page to Parent Page

  • # May 16, 2009 at 11:06 pm

    Hello Everyone,

    I am new to wordpress theme design and php, so please excuse me if this is rudimentary.
    I am trying to setup a wordpress site that has a video archive page similar to the one on CSS-Tricks.
    I have individual video pages created as a sub-page of the video archive page.
    On the video archive page I have the individual video pages linked to dynamically using..

    Code:
    < ?php
    $children = wp_list_pages('title_li=&child_of='.$post->ID.’&echo=0′);
    if ($children) { ?>

      < ?php echo $children; ?>

    < ?php } ?>

    Also on the individual video pages, I have a custom field setup called "thumb" that I place the URL of the post thumbnail in.
    I would like to access the custom field info from the parent video page and have the image display in the list item of the dynamically generated links.

    In other words I would like to dynamically load all the images from the sub-page custom field on parent page.

    I hope that this makes sense.

    Any help is much appreciated.

    # May 17, 2009 at 2:03 am

    Hi,

    As far as I know, you can only echo the meta data from inside "the_loop"

    This page has more info about Meta Data http://codex.wordpress.org/Using_Custom_Fields

    # May 19, 2009 at 5:32 pm

    Yeah that sounds about right. Perhaps you should do a well-executed query_posts() to get those child pages, so then you are inside the loop and have access to the page titles AND can grab that image that is a custom field.

    # May 21, 2009 at 7:39 pm

    If you only need a flat list of posts under the current page then simply using query_posts with a loop would be your best option. The only problem is if you have hierarchical pages, which would require nested lists, as that is a little more complicated to acheive and it is this that most of the magic inside wp_list_pages is dedicated to.

    I think you could use the following (untested) code as a starting point:

    Code:
    query_posts(“post_type=page&post_status=publish&post_parent=$post->ID&orderby=title&order=asc&showposts=-1″);
    if (have_posts()) : while(have_posts()) : the_post();

    echo ‘

  • ‘ . ‘ID) . ‘” title=”‘ . attribute_escape(apply_filters(‘the_title’, $post->post_title)) . ‘”>’ . ‘
  • ‘;

    endwhile; endif;

# May 27, 2009 at 7:04 am

How do they do this magic trick? You know that magic trick were a woman walks behind lets say a piece of wood that a guy is holding, she stands behind it for like 2 seconds and then shes wering different clothes to the one before she went behind the piece of wood. Could you please help me?
____________________
yahoo keyword tool ~ overture ~ traffic estimator ~ adwords traffic estimator

# May 27, 2009 at 8:39 am

It’s all done with smoke and mirrors.

# May 28, 2009 at 3:12 am

for some reason, I always subconsciously add "bananas" to the first line of every one of your posts…

Code:
It’s all done with smoke, bananas and mirrors.

oh…. wait a minute… :lol:

# May 28, 2009 at 10:17 am

smokey bananas… mmm delicious

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".