[Advanced Custom Field] Display child page under parent page
-
Hi everyone,
I have 12 child-pages that will be updating each month, I like to display the latest child-page under parent-page(landing page) dynamically. I used ACF’s True/False to define the latest page.(https://www.advancedcustomfields.com/resources/field-types/true-false/)
if( get_field('this_months_issue') ) { echo "<span class=\"issue-status\">/?This Month's Issue</span>"; } else { echo "<span class=\"issue-status\">/?Previous Issue</span>"; }
https://imageshack.us/a/img202/6249/checkboxr.jpg
https://imageshack.us/a/img541/2820/menurp.jpgso far the closest solution i found is to redirect it to the first child, the Jan (previous issue). I want it to be dynamic like if i updated March issue then it will land on March and not Jan. (https://www.wprecipes.com/wordpress-page-template-to-redirect-to-first-child-page)
<?php /* Template Name: Landing */ if (have_posts()) { while (have_posts()) { the_post(); $latestissue = get_pages("child_of=".$post->ID."&sort_column=menu_order"); if ($latestissue) { $firstchild = $latestissue[0]; wp_redirect(get_permalink($firstchild->ID)); } } } ?>
but i don’t know how to link it with the custom field value, anyone can help? Thank you very much in advanced.
- The topic ‘[Advanced Custom Field] Display child page under parent page’ is closed to new replies.