Last active
April 8, 2018 03:18
-
-
Save carlosjunod/aaa099bc3379369671d0570c122958ef to your computer and use it in GitHub Desktop.
Display only sub-pages of ID on the ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// display only sub-pages of a TARGET_PAGE on ACF_NAME custom field. | |
// https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/ | |
// in functions.php | |
function childpages_query( $args, $field, $post_ID ) { | |
$args = array( | |
'post_type' => 'page', | |
'posts_per_page' => -1, | |
'post_parent' => TARGET_PAGE_ID | |
); | |
return $args; | |
} | |
add_filter('acf/fields/relationship/query/name=ACF_NAME', 'childpages_query', 10, 3); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment