Skip to content

Commit

Permalink
fix: improve post organisation reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Dec 1, 2023
1 parent bc4f750 commit d7c81e6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion web/app/themes/awasqa/src/queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ function get_org_post_ids($org_id)
if (!$org_ids) {
$org_ids = [0];
}
$query['post__in'] = $org_ids;
// Add these in for better reliability, sometimes WPML fails to do this itself
$translated_post_ids = [];
foreach ($org_ids as $org_id) {
$en_id = apply_filters('wpml_object_id', $org_id, 'awasqa_organisation', true, 'en');
$es_id = apply_filters('wpml_object_id', $org_id, 'awasqa_organisation', true, 'es');
$translated_post_ids[] = $en_id;
$translated_post_ids[] = $es_id;
}
$query['post__in'] = array_merge($org_ids, $translated_post_ids);
# Prevent sticky posts from always appearing
$query['ignore_sticky_posts'] = 1;
return $query;
Expand Down

0 comments on commit d7c81e6

Please sign in to comment.