/**
  * the_content filter that will add linked posts to the bottom of the main post content
  *
  * @param $content
  *
  * @return string
  */
 public function run($content)
 {
     /**
      * Wow, what's going on here?! Well, setup_postdata() sets a lot of variables but does not change the $post variable.
      * All checks return the main queried ID but we want to check if this specific filter call is the for the 'main' content.
      * The method setup_postdata() does global and set the $id variable, so we're checking that.
      */
     global $id;
     // Only run on single
     if (!is_singular() || !is_main_query() || $id != get_queried_object_id()) {
         return $content;
     }
     // Allow disabling content filter
     if (false === apply_filters('rp4wp_append_content', true)) {
         return $content;
     }
     // The Post Type
     $post_type = get_post_type($id);
     // The Post Type Manager
     $pt_manager = new RP4WP_Post_Type_Manager();
     // Check if this Post Type is installed
     if ($pt_manager->is_post_type_installed($post_type) && isset(RP4WP()->settings['general_' . $post_type])) {
         // Related Post Manager
         $related_post_manager = new RP4WP_Related_Post_Manager();
         // The Output
         $output = $related_post_manager->generate_related_posts_list($id);
         // Add output if there is any
         if ('' != $output) {
             $content .= $output;
         }
     }
     // Return the content
     return $content;
 }
 /**
  * Generate the Related Posts for WordPress children list
  *
  * @param bool $id
  * @param bool $output
  * @param string $template
  * @param int $limit
  *
  * @since  1.0.0
  * @access public
  *
  * @return string
  */
 function rp4wp_children($id = false, $output = true, $template = 'related-posts-default.php', $limit = -1)
 {
     // Get the current ID if ID not set
     if (false === $id) {
         $id = get_the_ID();
     }
     // Get the post type
     $post_type = get_post_type($id);
     // Check if this Post Type is installed
     $pt_manager = new RP4WP_Post_Type_Manager();
     if ($pt_manager->is_post_type_installed($post_type) && isset(RP4WP()->settings['general_' . $post_type])) {
         // related Post Manager
         $related_post_manager = new RP4WP_Related_Post_Manager();
         // the Output
         $content = $related_post_manager->generate_related_posts_list($id, $template, $limit);
         // Output or return the content
         if ($output) {
             echo $content;
         } else {
             return $content;
         }
     }
 }