Viewing 15 replies - 16 through 30 (of 32 total)
  • Hi Ajay, I contacted the WPML Compatibility team, they are saying, that are waiting for your feedback. Would you please check if you received any follow up from them?

    Thanks in advance for your cooperation and willingness to make it fully compatible.

    Plugin Author Ajay

    (@ajay)

    Hi,

    That’s strange. I’ve written to them again.

    Plugin Author Ajay

    (@ajay)

    Hi,

    Just to update. I’m still waiting to hear back from the Developer assigned to handling Contextual Related Posts.

    Hello, any news?
    Thanks

    Plugin Author Ajay

    (@ajay)

    I haven’t heard anything from them. I’ve also chased a while but I guess they might be too busy to handle this.

    There isn’t much I can do without that.

    However, please see below if you can develop a similar function for CRP that I suggested for my other plugin called Top 10.

    https://www.ads-software.com/support/topic/top-10-and-wpml?replies=6

    Hello, this is what I received today from the WPML team:

    We have tried to reach Ajay on several ocassions from different e-mail accounts but it seems he cannot get our mails.
    We contacted him on

    July 17th
    September 11th
    October 20th
    November 4th
    December 2nd
    December 22nd

    But we have not heard back from him again. The last time we were in touch, as I can see it, was Oct 17th

    They wrote to me today and added you on CC. Did you receive this email?

    Plugin Author Ajay

    (@ajay)

    I didn’t receive any of their emails, except for this one. I’ve been in touch with them and they said they will send me emails on next steps

    Hi all,

    I started using this plugin and it seems pretty good. I also wanted it to work with WPML.

    Seeing this thread I went ahead and made modifications to my copy of the plugin so that it only recommends posts that are of the same language.

    I tried to make it work even if wpml is deactivated, so it should be safe.

    I didn’t do anything about translating the “Related Posts” text.

    The major code change occurs on line 359. I modified the $join string of the sql query.

    Hope this helps some people.

    I modified the contextual-related-posts.php file of the plugin. My modified version is below.

    https://gist.github.com/awhig/93e53e79c198ddbd73f5

    Rich

    Plugin Author Ajay

    (@ajay)

    Hi Rich,

    Thanks for the code. Let me look and see how I can incorporate this.

    I notice that the only change is at 359. Is that all that was required to make it compatible with WPML?

    Do you know if a function like this would work if you add this to your themes functions.php?

    function icl_crp_join( $join ) {
         global $wpdb;
    
         $join .= "  INNER JOIN {$wpdb->prefix}icl_translations ON {$wpdb->prefix}icl_translations.element_id= $wpdb->posts.ID AND {$wpdb->prefix}icl_translations.element_type='post_post' AND language_code='" . ICL_LANGUAGE_CODE . "' " ;
    
         return $join;
    }
    add_filter( 'crp_posts_join', 'icl_crp_join' );

    Note, I change the wp_ to {$wpdb->prefix} in two more places

    Hi Ajay,

    Yes. This is a much better way of making it WPML compatible.

    You left out the check to see that WPML is currently activated.

    I’ve modified the code to be:

    function icl_crp_join( $join ) {
         global $wpdb;
    
        if ( function_exists('icl_object_id') ) {
         $join .= "  INNER JOIN {$wpdb->prefix}icl_translations ON {$wpdb->prefix}icl_translations.element_id= $wpdb->posts.ID AND {$wpdb->prefix}icl_translations.element_type='post_post' AND language_code='" . ICL_LANGUAGE_CODE . "' " ;
        }
    
         return $join;
    }
    add_filter( 'crp_posts_join', 'icl_crp_join' );

    An additional disclaimer; I only use related posts on my posts page, not any pages. This code only looks for posts (element_type=’post_post’). If someone is also using the plugin for pages then they may want to modify this code.

    Rich

    Plugin Author Ajay

    (@ajay)

    Rich,

    Thanks for the update. For my benefit, what are the other element_type that they have?

    Because another version could be?

    $join .= "  INNER JOIN {$wpdb->prefix}icl_translations ON
              {$wpdb->prefix}icl_translations.element_id= $wpdb->posts.ID
              AND ( {$wpdb->prefix}icl_translations.element_type='post_post'
                 OR {$wpdb->prefix}icl_translations.element_type='post_page'
              )
              AND language_code='" . ICL_LANGUAGE_CODE . "' " ;

    Here are the distinct values I found in my table.

    comment
    post_
    post_page
    post_post
    tax_category
    tax_link_category
    tax_post_format
    tax_post_tag

    I don’t think your query is correct though. The elment_id could be the same between a post and a page (theoretically). You can’t just throw an OR statement in there.

    Sorry to saw though, after running the plugin for a couple of days I decided to turn it off as it caused 3X the load time of my pages (according to google crawl stats). Don’t think my server is good enough to get the speed I want.

    Good luck,
    Rich

    Plugin Author Ajay

    (@ajay)

    On the load times, have you turned on the Cache? Once the cache is running, the plugin only needs a single query to display the posts.

    Thanks for clarifying the table values. I believe, for users on post, your initial code should work:

    function icl_crp_join( $join ) {
         global $wpdb;
    
        if ( function_exists('icl_object_id') ) {
         $join .= "  INNER JOIN {$wpdb->prefix}icl_translations ON {$wpdb->prefix}icl_translations.element_id= $wpdb->posts.ID AND {$wpdb->prefix}icl_translations.element_type='post_post' AND language_code='" . ICL_LANGUAGE_CODE . "' " ;
        }
    
         return $join;
    }
    add_filter( 'crp_posts_join', 'icl_crp_join' );

    Hi Ajay,

    I’m using W3 Total cache, so I already have caching of my posts. I’m not using the plugin caching mechanism currently.

    I’m thinking when a crawler like google comes and crawls all my old pages (we have thousands), the load increases too much on the server, causing the avg. page load times to increase.

    Rich

    Plugin Author Ajay

    (@ajay)

    Rich,

    W3 Total cache is pretty good.

    However, CRP’s caching is different and using the database by saving the output directly in a meta field and it does this the first time the post is visited. Subsequent ones require a single query.

    Check out: https://wp-dreams.com/articles/2014/11/related-posts-plugins-performace-measured/

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘WPML and Contextual Related Posts’ is closed to new replies.