diff --git a/app/Controllers/App.php b/app/Controllers/App.php index ee5ec3c..92ae819 100644 --- a/app/Controllers/App.php +++ b/app/Controllers/App.php @@ -44,7 +44,7 @@ public function queriedResourceTerms() { $langs = get_language_list(pll_current_language('locale')); $terms = [ - 'language' => [], + 'resource_language' => [], 'lc_format' => [], 'lc_goal' => [], 'lc_region' => [], @@ -55,14 +55,16 @@ public function queriedResourceTerms() global $wp_query; if ($wp_query->tax_query) { foreach ($wp_query->tax_query->queries as $value) { - foreach ($value['terms'] as $t) { - $terms[$value['taxonomy']][$t] = get_term_by('slug', $t, $value['taxonomy'])->name; + if ($value['taxonomy'] !== 'language') { + foreach ($value['terms'] as $t) { + $terms[$value['taxonomy']][$t] = get_term_by('slug', $t, $value['taxonomy'])->name; + } } } } - if (isset($_GET['language'])) { - foreach ($_GET['language'] as $lang) { - $terms['language'][ $lang ] = $langs[$lang]; + if (isset($_GET['resource_language'])) { + foreach ($_GET['resource_language'] as $lang) { + $terms['resource_language'][ $lang ] = $langs[$lang]; } } return $terms; @@ -135,7 +137,7 @@ public function currentLanguage() return 'en'; } - public function foundPosts() + public function foundPosts($lang = 'en') { global $wp_query; return $wp_query->found_posts; @@ -393,10 +395,16 @@ public static function getPagination($args = []) return $navigation; } - public static function totalPosts($post_type = null) + public static function totalPosts($post_type = null, $lang = 'en') { if ($post_type) { - return wp_count_posts($post_type)->publish; + $q = new \WP_Query([ + 'post_type' => $post_type, + 'post_status' => 'publish', + 'lang' => $lang, + 'fields' => 'ids' + ]); + return $q->found_posts; } return 0; diff --git a/app/Controllers/FrontPage.php b/app/Controllers/FrontPage.php index c0a5e71..9552dff 100644 --- a/app/Controllers/FrontPage.php +++ b/app/Controllers/FrontPage.php @@ -27,7 +27,6 @@ public function mostViewed() 'post__not_in' => $viewed_ids, 'posts_per_page' => 4, 'fields' => 'ids', - 'lang' => '', ]); $ids = array_merge($viewed_ids + $unviewed_ids); @@ -36,7 +35,6 @@ public function mostViewed() 'post__in' => $ids, 'orderby' => 'post__in', 'posts_per_page' => 4, - 'lang' => '', ]); } @@ -48,7 +46,6 @@ public function recentlyPublished() 'orderby' => ['meta_value', 'date'], 'posts_per_page' => 4, 'order' => 'desc', - 'lang' => '', ]); } } diff --git a/app/filters.php b/app/filters.php index d380503..70316f3 100644 --- a/app/filters.php +++ b/app/filters.php @@ -135,11 +135,11 @@ break; } } - if (isset($_GET['language'])) { + if (isset($_GET['resource_language'])) { $meta_query = [ 'relation' => 'OR' ]; - foreach ($_GET['language'] as $lang) { + foreach ($_GET['resource_language'] as $lang) { $meta_query[] = [ 'key' => 'language', 'value' => $lang, @@ -149,7 +149,6 @@ } $query->set('posts_per_page', 12); $query->set('order', 'desc'); - $query->set('lang', ''); } } }); diff --git a/resources/views/partials/current-filters.blade.php b/resources/views/partials/current-filters.blade.php index f9b392c..5e32457 100644 --- a/resources/views/partials/current-filters.blade.php +++ b/resources/views/partials/current-filters.blade.php @@ -1,6 +1,6 @@ -@if(isset($_GET['s']) || $found_posts < App::totalPosts('lc_resource')) +@if(isset($_GET['s']) || $found_posts < App::totalPosts('lc_resource', $current_language))
{{ sprintf(__('%1$s of %2$s resources matched', 'coop-library'), $found_posts, App::totalPosts('lc_resource')) }}
+{{ sprintf(__('%1$s of %2$s resources matched', 'coop-library'), $found_posts, App::totalPosts('lc_resource', $current_language)) }}
@if(isset($_GET['s']))“{{ $_GET['s'] }}”
diff --git a/resources/views/partials/filters.blade.php b/resources/views/partials/filters.blade.php index fdb8d5a..d5233a9 100644 --- a/resources/views/partials/filters.blade.php +++ b/resources/views/partials/filters.blade.php @@ -70,7 +70,7 @@