• cwmuller

    (@cwmuller)


    I’d like to create a list of child pages, including some custom field date from each child page, and sort the entries by that date. I’m sure the code looks awful, but I am at beginner level at best, so bare with me. This is what i have so far:

    <?php
        $children = get_pages("child_of=" . $post->ID);
        if (!empty($children)) {
    	foreach($children as $child) {
    		$tittel = get_post_meta($child->ID, 'tittel', true);
    		$visningsdato = get_post_meta($child->ID, 'visningsdato', true);
    		$regiss?r= get_post_meta($child->ID, 'regiss?r', true);
    		$nasjonalitet= get_post_meta($child->ID, 'nasjonalitet', true);
    		$produksjons?r= get_post_meta($child->ID, 'produksjons?r', true);
    		$url= get_permalink($child->ID);
    		echo '<p><strong>' . $visningsdato . '</strong><br>';
    		echo '<a href="' . $url . '">' . $tittel. '</a> – '. $regiss?r . ', ' . $nasjonalitet . ', ' . $produksjons?r . '</p>';
            }
        }
    ?>

    So right now it fetches the data i want, but:

    1. I still need to format the date, because right now all I’m getting is YYYYMMDD.

    2. The list need to be sorted by custom field date.

    Does anyone have any suggestions as to how I can get started on this?

  • The topic ‘List child pages with custom fields’ is closed to new replies.