eddiehale
Member
Posted 3 months ago #
I want a list of child pages with custom fields -- and if there are grandchild pages a nested list of grandchild pages with custom fields.
I made a theme and maintain a site for a bike club. The list I described above would list their single-day events with (custom fields) date and location -- a nested list would show their multiple-day event series each with its own (custom fields) date and location.
See what I hard coded here -- if I could automate it with a loop, it would update whenever my client adds a new event.
http://rideviciouscycle.com/events/
Can you suggest some code? I would like it to work on the Events page and in the sidebar. I cannot write PHP from scratch. Thank you for help.
well I don't know how good you are with PHP but the process would be a somewhat simple.
I have to do the same thing but for attached files downloads.. I know it is not for you but it uses somewhat the same thing you need to do.
$post_meta = get_field('attachment_files');
// Get the number of the files that are attached to the post
$num = count($post_meta);
//print_r($post_meta);
//print $num;
if ($num > 0){
//print $post_meta[0]['attachment_file'];
if (!$post_meta[0]['attachment_file'] == ''){
for ($i = 0; $i < $num; $i++) {
// Get just the title of the file and strip any errors if any
$old = get_the_title($post_meta[$i]['attachment_file']);
$new = str_replace(get_the_title(),'', $old);
// Ouput of each file in a list
print '<a class="download_attachment" href="' . wp_get_attachment_url($post_meta[$i]['attachment_file']) . '" title="Download This Flier" target="_blank"><img src="'.home_url().'/wp-content/themes/black/assets/img/icons/pdf-icon.jpg" width="15"/>' . $new . '</a> <br />';
}
}
}
I hope it guides you in somewhat of the right idea on how to get it working
eddiehale
Member
Posted 2 months ago #
Justin, I looked at your code, but I am so inexperienced with PHP that I cannot decipher it. If anyone else has a snippet of code that comes closer to solving the problem described above, I would really appreciate seeing it.