How would I be able to get the page parent get the custom values of all page children?
I found a plugin that does exactly what I want, however, I will kkep this thread open, just in case someone else finds a different way of doing this
http://blog.ftwr.co.uk/wordpress/query-child-of-page/
I spent really a long time googling this and I also tried the plugin gabesands links to, but still no luck. So I have to raise the question again: How do I display a custom field from a subpage on a parent page? Held would be really appreciated.
Did you try this? I am not sure if this is what you look for exactly.
$customs = get_posts('numberposts=-1&post_type=page&post_parent=1&meta_key=test_value');
foreach($customs as $custom) {
print get_post_meta($custom->ID, 'test_value', $single = true);
print '<br />';
}
Querying posts that are “pages” and child of ID 1 and returning pages only with custom field “test_value” then prints the value of custom key in a loop.
Thanks a lot, that did the trick.
A related question: I have several subpages with film reviews, each page has the custom field “regisseur” (=director), the title of the page is the respective film title. What I want is that all reviews are displayed as a a list. This works in principle with the following code:
<?php $customs = get_posts('numberposts=-1&post_type=page&post_parent=28&sort_column=post_title&order=ASC');
foreach($customs as $custom) {
$post_id_art = get_post($custom->ID, ARRAY_A);
$title = $post_id_art['post_title'];
$url = $post_id_art['guid'];
print "<a href=\"";
print $url;
print "\"><em class=\"Film\">";
print $title;
echo "</em></a>";
echo " von ";
print get_post_meta($custom->ID, 'Regisseur', $single = true);
print '<br />';
} ?>
See here
The problem is the sort order: I want the list displayed in alphabetical order. For some reason “&sort_column=post_title&order=ASC” is just ignored, instead the list is sorted by the pages IDs.
Any ideas?