cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
279 stars 83 forks source link

WPP Doesn't Follow The Current Language with WPML #274

Closed fatihturan closed 3 years ago

fatihturan commented 4 years ago

Describe the bug I have a Web site with multi-language posts (Turkish and English) that I am using WPP along with WPML for showing the most popular 3 posts. But it's showing Turkish contents on the English language and vice versa. So WPP doesn't follow the current language of the Web site.

<?php
$cta_caption = get_field('resources_most_read_cta_caption', 'options');
if (function_exists('wpp_get_mostpopular')) {
        wpp_get_mostpopular(array(
            'limit' => 3,
            'excerpt_length' => 60,
            'wpp_start' => '',
            'wpp_end' => '',
            'post_html' => '<div class="most-read__list-item">
                <a href="{url}" class="primary-card primary-card--article">
                    <h6>{text_title}</h6>
                    <p>{summary}</p>
                    <div class="primary-card__bar"></div>
                    <button type="button">' . $cta_caption . '
                        <svg xmlns="http://www.w3.org/2000/svg" width="17" height="11" viewbox="0 0 20 16"> <g fill="none" fill-rule="evenodd" stroke="#162a4c" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"> <path d="M11 15l8-7-8-7M19 8H1" /> </g> </svg>
                    </button>
                </a>
            </div>'
        ));
}
?>

Plugin Configuration

System Info

cabrerahector commented 4 years ago

Hi @fatihturan,

Just tried your code with WPML 4.3.11 and the TwentyTwenty theme and it worked for me just fine:

Did you make sure that your popular posts have a translation available for each language?

fatihturan commented 4 years ago

Did you make sure that your popular posts have a translation available for each language?

I checked out the our posts and I just see our editor created separate posts for each languages without connecting them. This is our mistake. Sorry for missing that.

But is there a way to display popular posts with specific languages with WPP? I don't want to show posts even for under this scenario.

cabrerahector commented 4 years ago

Unfortunately no. WPP expects all posts to have a translation available when used in conjunction with translation plugins such as WPML or Polylang.

cabrerahector commented 3 years ago

Closing due to inactivity.