Plugin Author
Ajay
(@ajay)
The plugin doesn’t come with out of the box support for Polylang.
On line 379, I have:
$result = get_post(apply_filters('tptn_post_id',$result->ID)); // Let's get the Post using the ID
You can write a function using add_filter which can be used to overwrite the language.
I’m not familiar with Polylang’s API. Please see this thread on using Top 10 with WPML and a sample function (I’ve not got confirmation on if its been tested).
http://wordpress.org/support/topic/top-10-and-wpml?replies=6
Thanks for the response Ajay.
Found out that with the way Polylang works, it’s actually fine, I can just call the query using “meta_value_num” in combination with it.
Plugin Author
Ajay
(@ajay)
Would this be independent of Top 10? Or do you have a working code that might help other users with both plugins?
Hi Ajay
Polylang basically doubles Posts. I started with english versions and then I created a spanish site with all the posts that is translated to spanish. They are distinguished by the “lang” taxonomy, so if I want to put up bunch of posts, I would just need to include that taxonomy in the array.
To my understanding if Top 10 updates “meta_value_num” and “meta_key” values, the query would find the right posts using all these taxonomies in combination.
For example:
<?php query_posts( array( ‘meta_key’ => ‘views’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ ), ‘lang’ => ‘en’ ); ?>
(note that meta_key can also be: ‘meta_key’ => ‘views’ depending on how a specific plugin works)
Does this help?
Plugin Author
Ajay
(@ajay)
Hi,
So if I understand correct, the English version has a post ID and the Spanish version has a different post ID?
If that is the case, then most likely Top 10 is counting the hits independently. These are saved in separate tables containing “tptn” in your WordPress database.
What you can try for now is get the posts IDs only using code similar to this (again, it’s not tested):
$toppostsid = tptn_pop_posts('limit=10&posts_only=1');
return new WP_Query( array(
'post__in' => wp_list_pluck( $toppostsid, 'ID' ),
'posts_per_page' => 3,
'ignore_sticky_posts' => true,
'post__not_in' => array( $post->ID ),
'tax_query' => array(
array(
'taxonomy' => 'lang',
'field' => 'slug',
'terms' => 'en'
)
)
Note that I’m going to be changing the above implementation of tptn_pop_posts in a future version which makes it easier to just get the top post IDs.
Ok thanks, I still need to work on all this and will let you know if there are any problems.
Looks pretty clear.
Thanks for the help.
Plugin Author
Ajay
(@ajay)
You’re welcome. Do let me know the results. I plan on updating the FAQ to guide other visitors and this will definitely help.