WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Related Posts
[resolved] conflict with qtranslate plugin? (9 posts)

  1. christian70
    Member
    Posted 2 years ago #

    related posts is a great wp plugin, but if qtranslate plugin is installed as on my template it seems to work unproperly because both titles (in italian and english too) are displayed. any suggestion to let the language switcher work fine even in related post widget?

    http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/

  2. Sam Hotchkiss
    Member
    Posted 2 years ago #

    I've come up with a patch:

    With the latest version (1.2), add:

    if(function_exists('qtrans_postsFilter')) :
    		$related_posts = qtrans_postsFilter($related_posts);
    	endif;

    To line 84.

    With older versions, just find this line and put it in before:

    foreach ($related_posts as $related_post ){

    Hope this helps!

    Sam
    http://hotchkissconsulting.net/

  3. cbarnett
    Member
    Posted 1 year ago #

    This patch doesn't seem to work with the NOW latest version (1.7)

    I tried adding the code specific for (1.2) after line 85 and my related posts still show up all languages mashed together in one string.

    Any suggestions for using a patch for qTranslate with this plugin v1.7?

    I would appreciate the help, thanks.

  4. cbarnett
    Member
    Posted 1 year ago #

    Hey - an update. I figured out how to make this patch work with the latest version (1.7)

    In wp_related_posts.php

    Add the following to line 80:

    if(function_exists('qtrans_postsFilter')) :
    	$related_posts = qtrans_postsFilter($related_posts);
    	endif;

    This ends up appearing like this (between the lines of code shown):

    $related_posts = $wpdb->get_results($q);
    	}
    
    	if(function_exists('qtrans_postsFilter')) :
    	$related_posts = qtrans_postsFilter($related_posts);
    	endif;
    
    	return $related_posts;
    }

    Anyway, this is working for me now (yay!) so I hope it helps other people out there!!!

  5. cbarnett
    Member
    Posted 1 year ago #

    My main gripe with this Plugin is relating to this qTranslate issue. I reviewed the plugin asking if it would be possible to just integrate this three lines of code into the future updates so it plays nice with qTranslate - so we who use multiple languages on this website no longer have to fiddle with the code and add in the patch every time it is updated.

    But, regardless, as of the 2.0.2 update, we were again able to patch the plugin similarly to before, and I wanted to share how with anyone else who may be using the qTranslate plugin in combination with this Related Posts plugin:

    To patch the latest version of this plugin (v2.0.2) so it works with qTranslate

    In wp_related_posts.php

    Add the following to line 90:

    if(function_exists('qtrans_postsFilter')) :
    	$related_posts = qtrans_postsFilter($related_posts);
    	endif;

    This ends up appearing like this (between the lines of code shown):

    }
    
    function wp_rp_fetch_posts_and_title() {
    	$options = wp_rp_get_options();
    
    	$limit = $options['max_related_posts'];
    	$title = $options["related_posts_title"];
    
    	$related_posts = array();
    
    	wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts_v2');
    	wp_rp_append_posts($related_posts, 'wp_rp_fetch_related_posts');
    	wp_rp_append_posts($related_posts, 'wp_rp_fetch_random_posts');
    
    if(function_exists('qtrans_postsFilter')) :
    	$related_posts = qtrans_postsFilter($related_posts);
    	endif;
    
    	return array(
    		"posts" => $related_posts,
    		"title" => $title
    	);
    }

    Hopefully the developer will consider making this patch in his future updates. I know he's working for free though - and that can be difficult. My company is planning to donate to all the plugin developers whose plugins we are currently integrating into our new website. I encourage all of you to consider donating to these developers as well. Especially if you use it for your business websites!

  6. xdaseinx
    Member
    Plugin Author

    Posted 1 year ago #

    Hi!

    Yes yes, we're considering on supporting this. Give us a few weeks to get ready. :)

  7. cbarnett
    Member
    Posted 1 year ago #

    Hi, thank you - that would be awesome!!! I'm looking forward to it!

  8. cbarnett
    Member
    Posted 1 year ago #

    I am happy to see you included the qTranslate compatibility with the newest version - and it indeed seems to be working as it should! Thank you!

  9. xdaseinx
    Member
    Plugin Author

    Posted 1 year ago #

    Happy new year! :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic