Related Posts extended


 2011-10-20 02:42:08



Dear friend, great plugin relatedPost


I made the addition and extension of thumbs and post excerpt, not absolutely waterproof but good enough for most. Couldn’t log into your website for some “re-capture” reason, so please post it yourself on your forum, might help others.

 to publish it it needs the optional paras set, as is now its default, is 10min extra work.

and the replacement for the default thumb in efficient related posts


tx for the great plugin!





Replace following function in file efficient-related-posts.php





                 * @param [optional]$args Array of arguments containing any of the following:

                 *            [num_to_display]           – Number of Posts to display

                 *            [no_rp_text]                     – Text to display if there are no related posts

                 *            [title]                                                   – Title for related posts list, empty for none


                public function getRelatedPosts( $args = array() ) {

                               global $post;

                               $output = “;


                               $settings = wp_parse_args($args, $this->_settings[‚erp‘]);


                               $relatedPosts = get_post_meta($post->ID, ‚_efficient_related_posts‘, true);


                               if ( empty($relatedPosts) || $settings[’num_to_display‘] == 0 ){


                                                * @todo The before and after setting should apply to this too


                                               $output .= „<li>{$settings[’no_rp_text‘]}</li>“;

                               } else {

                                               $relatedPosts = array_slice($relatedPosts, 0, $settings[’num_to_display‘]);

                                               foreach ( $relatedPosts as $p ) {


                                                                * Handle IDs for backwards compat


                                                               if ( ctype_digit($p) ) {

                                                                              $related_post = get_post($p);

                                                                              $p = array(

                                                                                              ‚ID‘                                         => $related_post->ID,

                                                                                              ‚post_title‘          => $related_post->post_title,

                                                                                              ‚permalink‘                         => get_permalink($related_post->ID)



                                                               $link = „<a href='{$p[‚permalink‘]}‘ title='“ . esc_attr(wptexturize($p[‚post_title‘])).“‚>“.wptexturize($p[‚post_title‘]).'</a>‘;



                                                               $backup = $post;

                            $pp = get_post($p[‚ID‘]);

                            $thumb = get_the_post_thumbnail($pp->ID, ‚thumbnail‘, array(‚class‘ => ‚RelPosts‘));   


                if (empty($thumb)) {

                      $thumb = „<img width=’150′ height=’133′ src=’×133.jpg‘ class=’RelPosts wp-post-image‘ alt=’Retzek forscht‘ title=’Retzek verschweinzt Naechte und Wochenenden um die Wahrheit auszugraben‘>“;





                                                               If ($pp->post_excerpt != “){

                                                               // get the users excerpt

                                                                              $excerpt = $post->post_excerpt;


                                                               Else {

                                                               // Create the excerpt

                                                               $excerpt = $pp->post_content;

                                                               $excerpt = strip_shortcodes( $excerpt );

                                                               $excerpt = apply_filters(‚the_content‘, $excerpt);

                                                               $excerpt = str_replace(‚]]>‘, ‚]]&gt;‘, $excerpt);

                                                               $excerpt = strip_tags($excerpt);

                                                               $excerpt_length = apply_filters(‚excerpt_length‘, 55);

                                                               $excerpt_more = apply_filters(‚excerpt_more‘, ‚[…]‘);

                                                               $words = explode(‚ ‚, $excerpt, $excerpt_length + 1);

                                                               If ( Count($words) > $excerpt_length ){


                                                                 Array_Push($words, $excerpt_more);

                                                                 $excerpt = Implode(‚ ‚, $words);




                                                 // Run filters – there is a bug if you try to run an empty excerpt through the filter

                                                 If ($excerpt != “) $excerpt = apply_filters(‚get_the_excerpt‘, $excerpt);


                          $post = $backup;                                   


                                                                /* @todo Make a before and after setting for this


                                                               $output .= „$thumb <li>{$link}<div><p class=’RelPosts‘>$excerpt</p></div></li><div style=’clear:both;‘>&nbsp</div>“;





                                * @todo Make a before and after setting for this


                               $output = „<ul class=’related_post‘>{$output}</ul>“;


                               if ( !empty($settings[‚title‘]) ) {

                                               $output = „<div class=’RelPostHeli‘><h3 class=’related_post_title‘>{$settings[‚title‘]}</h3>{$output}</div>“;



                               return $output;










div.RelPostHeli {margin:-20px;padding:20px;background-color:snow;}

ul.related_post li p.RelPosts {font-size:11px;color:grey;margin:5px 0 10px 10px;}

ul.related_post li div p.RelPosts img.RelPosts, ul.related_post img.RelPosts { 

    background: none repeat scroll 0 0 lavender;

    float: left;

    height: 120px;

    left: -20px;

    margin: 2px 42px 4px -24px;

    padding: 8px;

    top: -10px;

    width: 120px;







(Visited 48 times, 1 visits today)
blank Helmut B Retzek
Arzt für Allgemeinmedizin, multiple präventivmedizinische, schulmedizinische und komplementäre Zusatzausbildungen. Wissenschaftliche Arbeit und Forschungs-BeiträgeZahlreiche Artikel und Vorträge.  Diese Website dokumentiert umfangreiche eigene Recherchen in der aktuellen medizinischen Forschung zum Zweck der Selbst-Weiterbildung und als Gedächtnis-Stütze. Mässige Legasthenie, daher Rechtschreib- und Beistrichfehler, bitte nicht kommentieren, wer es nicht aushält bitte einfach nicht lesen
Ärztekammer Disclaimer
Ärztekammmer Disclaimer die Oberösterreichische Ärztekammer moniert weite Teile diese Website als „aufdringlich, marktschreierisch und beim Laien den Eindruck medizinischer Exklusivität erweckend“. Dies ist keinesfalls beabsichtigt, die Website ist ein absichtsloses Weiterbildungsmedium von Dr. Retzek, der seine wissenschaftlichen Pubmed-Recherchen hier mit ärztlichen Kollegen unentgeltlich teilt, wofür Dr. Retzek von vielen Kollegen aus dem In- und Ausland regelmässig Anerkennung ausgesprochen bekommt. Dass Wissenschaftsrecherchen und Studien „das Standesansehen der Ärzte“ verletzen könnte, war Dr. Retzek nicht bewusst, er bedauert dies zutiefst und entschuldigt sich bei den betroffenen Kollegen.
Kommentare ansehen oder einen Kommentar schreiben

Kommentar gerne erwüscht wenn sie hilfreich für Leser sind

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.