Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ajay

    (@ajay)

    Marcelo,

    I don’t have access to WPML. Is it possible to contact the WPML team to understand the best way to fetch posts? You could probably tell them this is how Top 10 works.

    Top 10 works in a very simplistic manner. It tracks a hit and saves the post ID in the database. To fetch the list of posts, the plugin uses:

    $result = get_post($result->ID);

    and

    get_the_title($result->ID)

    The outputs of these are displayed at the bottom of your page.

    Thread Starter marcelgo

    (@marcelgo)

    OK, I try that and keep you updated
    Thank you ??

    Thread Starter marcelgo

    (@marcelgo)

    Ajay,
    I think it should be something like this: https://wpml.org/forums/topic/get_posts-by-language/#post-63119 right?

    Which file and line do I have to edit to try that? Or even better, is there a way to get this done with a custom hook in my functions file???

    Plugin Author Ajay

    (@ajay)

    The first option is line 336 of top-10.php

    $result = get_post($result->ID);        // Let's get the Post using the ID

    The second options doesn’t work currently, but it might be something along the lines of:

    $result = apply_filters("tptn_post_id",get_post($result->ID));        // Let's get the Post using the ID

    You could then add the custom hook. Do let me know if this way works and I’ll add it to the plugin code as well.

    Plugin Author Ajay

    (@ajay)

    Marcelgo,

    I updated the plugin to include a new filter. You’ll need to get hold of 1.9.8.5

    Try this piece of code in your functions file and let me know if this works.

    function tptn_lang_dep_id($id){
      if(function_exists('icl_object_id')) {
        return icl_object_id($id,'post',true);
      } else {
        return $id;
      }
    }
    add_filter('tptn_post_id','tptn_lang_dep_id');
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Top 10 and WPML’ is closed to new replies.