Title: ayako1012's Replies | WordPress.org

---

# ayako1012

  [  ](https://wordpress.org/support/users/ayako1012/)

 *   [Profile](https://wordpress.org/support/users/ayako1012/)
 *   [Topics Started](https://wordpress.org/support/users/ayako1012/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ayako1012/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ayako1012/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ayako1012/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ayako1012/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ayako1012/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Can't show my child posts on parent posts](https://wordpress.org/support/topic/cant-show-my-child-posts-on-parent-posts/)
 *  Thread Starter [ayako1012](https://wordpress.org/support/users/ayako1012/)
 * (@ayako1012)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/cant-show-my-child-posts-on-parent-posts/#post-4441486)
 * Dear Agnes,
 * Thank you for your reply.
    I’m afraid but I think [Post 2 Post](http://wordpress.org/plugins/posts-to-posts/)
   plugin leaves us more parts we can coding.
 * So, I decided to try to make it with [Post 2 Post](http://wordpress.org/plugins/posts-to-posts/)
   plugin, but again I have some problem.
 * I added
 *     ```
       /**
        * Related Post Connection
        * @author Bill Erickson
        * @link http://www.billerickson.net/manually-curated-related-posts/
        *
        * @uses Posts2Posts
        * @link https://github.com/scribu/wp-posts-to-posts/wiki
        */
       function be_post_type_connections() {
   
       	p2p_register_connection_type( array(
       		'name' => 'related-articles', // unique name
       		'from' => 'post',
       		'to' => 'post',
       		'title' => array( 'to' => 'All Connections', 'from' => 'Related Articles' )
       	) );
       }
       add_action( 'p2p_init', 'be_post_type_connections' );
   
       /**
        * Related Posts Before Loop
        * Adds connection data to $wp_query. Run before the loop.
        *
        * @author Bill Erickson
        * @link http://www.billerickson.net/manually-curated-related-posts/
        */
       function be_related_posts_pre_loop() {
        	// Make Sure plugin is active
        	if ( !function_exists( 'p2p_register_connection_type' ) )
       		return;
   
       	global $wp_query;
       	p2p_type( 'related-articles' )->each_connected( $wp_query );
       }
       /**
        * Display Related Posts
        * @author Bill Erickson
        * @link http://www.billerickson.net/manually-curated-related-posts/
        */
       function be_related_posts() {
        	// Make Sure plugin is active
        	if ( !function_exists( 'p2p_register_connection_type' ) )
       		return;
   
       	global $post;
       	if( isset( $post->connected ) && !empty( $post->connected ) ):
       		echo '<div class="related-posts">';
       		$count = 1;
       		foreach( $post->connected as $related ):
       			if( $count < 6 ) {
       				echo '<div class="related-post">';
       				echo '<a class="image" href="' . get_permalink( $related->ID ) . '">';
       				$cat = wp_get_object_terms( $related->ID, 'category', array( 'count' => 1 ) );
       				echo '<span class="category">' . $cat[0]->name . '</span>';
       				echo get_the_post_thumbnail( $related->ID, 'be_home_small' );
       				echo '</a>';
       				echo '<a class="title" href="' . get_permalink( $related->ID ) . '">' . $related->post_title . '</a>';
       				echo '</div>';
       				$count++;
       			}
       		endforeach;
       		echo '</div>';
       	endif;
       }
       ```
   
 * to my function.php but the related posts never appears on each posts.
 * If you know about this, I beg your ideas.

Viewing 1 replies (of 1 total)