• Resolved M.

    (@mlepore)


    Hi

    The plugin is working great so far on the primary language, now after enbabling the second language, it does not show any posts there.

    Polylang is being used on the site. Translated posts do exist.

    Currently used code on the page is

    $args = array(
    'post_type' => 'post',
    'cat' => implode(',', $sub_cat_list),
    'order_by' => 'views',
    'range' => 'last30days',
    'limit' => '5',
    'pid' => implode(', ', $sticky_posts),
    'post_html' => '<li><a class="popular-post" href="{url}">{text_title}</a></li>'    
    );                                   
    
    wpp_get_mostpopular($args);

    I even tried to add lang variable like

    'lang' => pll_current_language('slug')

    Is there something im missing here?

    Thanks and KR

    M

    • This topic was modified 9 months ago by M..
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @mlepore,

    Just tested Polylang with WPP and it seems to be working as expected here, WPP is listing the translated version of the popular posts under the current language.

    Please make sure that your popular posts have a translation available on the second language or else WPP will list the original version instead (as shown on the screenshot above.)

    Thread Starter M.

    (@mlepore)

    Hi Hector

    Thanks for the quick reply.

    Is there any way i could debug why it does not return any articles?

    On the primary language is it quite well working and with the same code as its added in page.php of the theme, it does not return any articles at all in any other language.

    All articles have translated articles in the secondary languages, so it should return atleast something, but wpp_get_mostpopular() with above settings does not return anything at all.

    • This reply was modified 9 months ago by M..
    Plugin Author Hector Cabrera

    (@hcabrera)

    It’s this:

    'cat' => implode(',', $sub_cat_list)

    Looks like filtering by category + Polylang might not be working at the moment. I’ll look into that as soon as I can.

    Thread Starter M.

    (@mlepore)

    Hi Hector

    Sorry to bother you, are there any news on this topic, or possibly any “workaround” i can do until its fixed properly?

    KR

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey there, good day.

    Sorry, I don’t have any updates to share at this time. Haven’t had the time to look into this yet.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @mlepore, good day!

    Quick update: reverted a change in the plugin that broke filtering by category ID when using Polylang (or WPML). I should be releasing a new version sometime tomorrow if nothing else comes up.

    Plugin Author Hector Cabrera

    (@hcabrera)

    And version 6.4.2 is out! Please update and if you have any comments / questions do let me know.

    Thread Starter M.

    (@mlepore)

    Hi @hcabrera

    Thank you for the update.

    I have at this moment 4 languages on my WP, all with translated posts on it. But it seems to still not show any translated posts.

    Is there anything i can debug to see why it not working now on version 6.4.2. ?

    KR

    Plugin Author Hector Cabrera

    (@hcabrera)

    Make sure that the category IDs you’re passing to the function come from your main language categories. If you’re already doing that then I’d need to see more of your code + reproduction steps so I can help.

    Thread Starter M.

    (@mlepore)

    Hi @hcabrera

    Here is the relevant code used for display on page.php of the theme.

    Getting the parent categories

    $categories = get_terms([
    'taxonomy'   => 'category',
    'hide_empty' => false,
    'parent'     => 0,
    'exclude'    => array(1,7,11,15,53,117,119,221)
    ]);

    Gathering the Subcategories

    foreach ($categories as $category) 
    ...
    
    $sub_categories = get_categories([
        'child_of'   => $category->term_id,
        'hide_empty' => false,
        'orderby'    => 'order',
        'order'      => 'ASC',
    ]);
    
    $sub_cat_list[] = $category->term_id;
    foreach ($sub_categories as $sub_category) {
        $sub_cat_list[] .= $sub_category->term_id;
    }

    wpp call

    $args = array(
        'post_type' => 'post',
        'cat'       => implode(',', $sub_cat_list),
        'order_by'  => 'views',
        'range'     => 'last30days',
        'limit'     => '5',
        'pid'       => implode(', ', $sticky_posts),
        'post_html' => '<li><a class="popular-post"   href="{url}">{text_title}</a></li>'
    );
                                            wpp_get_mostpopular($args);
    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, it seems that your code pulls category IDs from secondary languages. As mentioned above, you’ll want to provide main language category IDs to the function instead.

    Thread Starter M.

    (@mlepore)

    Hi @hcabrera

    Sorry missed that, after adding the lang to the get category, it works fine.

    Thank you.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘No results in secondary language’ is closed to new replies.