/** * Output the shortcode * * @since 1.3.0 * @access public * */ public function output($atts) { $atts = shortcode_atts(array('id' => get_the_ID(), 'limit' => -1), $atts); // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Generate the children list return $pl_manager->generate_children_list($atts['id'], $atts['limit']); }
/** * Output the shortcode * * @since 1.3.0 * @access public * */ public function output() { // Get the current ID $id = get_the_ID(); // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Generate the children list echo $pl_manager->generate_children_list($id); }
/** * Generate the Related Posts for WordPress children list * * @param bool $id * @param bool $output * * @since 1.0.0 * @access public * * @return string */ function rp4wp_children($id = false, $output = true) { // Get the current ID if ID not set if (false === $id) { $id = get_the_ID(); } // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Generate the children list $content = $pl_manager->generate_children_list($id); // Output or return the content if ($output) { echo $content; } else { return $content; } }
public function widget($args, $instance) { // Get the current ID $id = get_the_ID(); // Not on frontpage please if (is_front_page() && false === is_page()) { return; } // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Get content $widget_content = $pl_manager->generate_children_list($id); // Only display if there's content if ('' != $widget_content) { // Output the widget echo $args['before_widget']; echo $widget_content; echo $args['after_widget']; } }
/** * 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; } // Post Link Manager $pl_manager = new RP4WP_Post_Link_Manager(); // Generate the content $content .= $pl_manager->generate_children_list($id); // Return content return $content; }