Last active
December 12, 2017 17:39
-
-
Save johnmccole/25f4619f4bee04d40e9e293f0f25fc27 to your computer and use it in GitHub Desktop.
Copy to you themes template, update the name of the CPT as required.
This file contains hidden or 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 | |
global $post; | |
if ( isset ($post) ){ | |
$post_parent = $post->ID; | |
if ( !empty($post->post_parent) ){ | |
$post_parent = $post->post_parent; | |
} | |
$args = array( 'posts_per_page' => -1, 'post_parent' => $post->post_parent, 'post_type'=> 'custom-post-name' ); | |
$myposts = get_posts( $args ); | |
foreach ( $myposts as $post ) : setup_postdata( $post ); ?> | |
// html content | |
<?php endforeach; | |
wp_reset_postdata(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment