Home > WordPress > Adjust MicroKid Related Posts v2.4 with qTranslate v2.4.3 Plugins

Adjust MicroKid Related Posts v2.4 with qTranslate v2.4.3 Plugins

Today, I received one notification about the update available for MicroKid Related Posts plugin that I have been using it since version 2.3. It was changed from 2.3 to 2.4. According to its change log, there were 4 main things that changed:

  1. You can now add drafts and planned posts as related posts, without them appearing on your site before they are properly published.
  2. Added shortcode support: you can now place the [ related-posts ] shortcode within the content of your post to display the related posts anywhere you want.
  3. (For advanced users) Added a parameter to the MRP_get_related_posts function to optionally get the related posts in an object, so you can easily use it in other plugins or your own custom way of displaying the list of related posts. For documentation on this, see [the API section](http://www.microkid.net/wordpress/related-posts/#API “Microkids Related Posts API functions”).
  4. (For advanced users) Added a parameter to the MRP_get_related_posts function to optionally include unpublished posts to the related posts list. For documentation on this, see [the API section](http://www.microkid.net/wordpress/related-posts/#API “Microkids Related Posts API functions”).

After the automatically-upgrade process was completed, I remembered that I had modified this Microkids Related Post plugin before via this article: Adjust MicroKid Related Posts v2.3 with qTranslate v2.4.3 Plugins. It meant that I had to adjust its new script again in order it compatible with qTranslate plugin.

So here was I made:

  1. Open mrp-search.php file, find this code:
    52
    
    foreach( $results as $result ) {

    replace with:

    52
    53
    
    foreach( $results as $result ) {
    $related_post_title = wp_specialchars(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($result->post_title));

    find this code:

    60
    
    echo $result->post_title;

    replace with:

    60
    
    // echo $result->post_title;

    find this code:

    64
    
    echo '</a> <a href="'.get_permalink( $result->ID ).'" title="View this post" class="MRP_view_post" target="_blank">&rsaquo;</a></li>';

    replace with:

    64
    
    echo $related_post_title.'</a> <a href="'.get_permalink( $result->ID ).'" title="View this post" class="MRP_view_post" target="_blank">&rsaquo;</a></li>';

    then save this file.

  2. Open microkids-related-posts.php file, and find this code:
    104
    
    echo '<li id="related-post-'.$related_post->ID.'"><span>'.$post_title.'</span><span><a class="MRP_deletebtn" onclick="MRP_remove_relationship(\'related-post-'.$related_post->ID.'\')">X</a></span>';

    replace with:

    104
    
    echo '<li id="related-post-'.$related_post->ID.'"><span>'.wp_specialchars(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($post_title)).'</span><span><a class="MRP_deletebtn" onclick="MRP_remove_relationship(\'related-post-'.$related_post->ID.'\')">X</a></span>';

    find this code:

    328
    329
    330
    331
    332
    
    $output .= "<ul>\n";
    foreach( $related_posts as $related_post  ) {
      $output .= "<li><a href=\"".get_permalink( $related_post->ID )."\" title=\"$related_post_title\">".$related_post->post_title."</a></li>\n";
    }
    $output .= "</ul></div>\n";

    replace with:

    328
    329
    330
    331
    332
    
    $output .= "<ol>\n";
    foreach( $related_posts as $related_post  ) {
      $output .= "<li><a href=\"".get_permalink( $related_post->ID )."\" title=\"$related_post_title\">".wp_specialchars(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($related_post->post_title))."</a></li>\n";
    }
    $output .= "</ol></div>\n";

    find this code:

    375
    376
    377
    378
    379
    
    echo "<ul>\n";
    foreach( $related_posts as $related_post_id => $related_post_title  ) {
      echo "<li><a href=\"".get_permalink( $related_post_id )."\" title=\"$related_post_title\">".$related_post_title."</a></li>\n";
    }
    echo "</ul></div>";

    replace with:

    375
    376
    377
    378
    379
    380
    
    echo "<ol>\n";
    foreach( $related_posts as $related_post_id => $related_post_title  ) {
      echo "<li><a href=\"".get_permalink( $related_post_id )."\" title=\"$related_post_title\">".wp_specialchars(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($related_post_title))."</a></li>\n";
    }
    echo "</ol>
    </div>";

This has been tested and working good in Microkids Related Posts version 2.4 and qTranslate version 2.4.3.

  • Share/Bookmark
232 views Print This Post Print This Post