Skip to content

Instantly share code, notes, and snippets.

@barrykooij
Created February 18, 2019 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrykooij/9dcb4c4b26e3bd4f9af243940a7e2bb9 to your computer and use it in GitHub Desktop.
Save barrykooij/9dcb4c4b26e3bd4f9af243940a7e2bb9 to your computer and use it in GitHub Desktop.
<?php
// Get the connected posts
$child_posts = Post_Connector::API()->get_children( "course", get_the_id() );
$parent_posts = Post_Connector::API()->get_parents( "course", get_the_id() );
$my_connected_posts = array_merge( $child_posts, $parent_posts );
// Check
if ( count( $my_connected_posts ) > 0 ) {
// Loop
foreach ( $my_connected_posts as $my_connected_post ) {
// Display the title with a link
echo "<a href='" . get_permalink( $my_connected_post->ID ) . "'>" . $my_connected_post->post_title . "</a><br/>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment