Skip to content

Instantly share code, notes, and snippets.

@Shoora
Forked from daltonrooney/gist:3182528
Last active February 28, 2019 03:41
Show Gist options
  • Save Shoora/6384400 to your computer and use it in GitHub Desktop.
Save Shoora/6384400 to your computer and use it in GitHub Desktop.
wordpress dispay page parent
<?php $args = array(
'numberposts' => -1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'custom_post_type_here',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'custom_field_key_name',
'value' => $post->ID,
'compare' => 'LIKE'
)
)
);
$posts_array = get_posts( $args );
if( $posts_array ) {
echo '<ul>';
foreach( $posts_array as $related ) {
echo '<li>';
echo '<a href="' . get_permalink( $related->ID ) . '">' . $related->post_title . '</a>';
echo '</li>';
}
echo '</ul>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment