updating post Sorting algorythm to handle poste title
This commit is contained in:
parent
a8c091f272
commit
c1f9be6366
|
|
@ -127,9 +127,6 @@ function show_post_type_label_name($post_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------
|
/* ---------
|
||||||
SORT BY THEMATIQUE PRIORITY
|
SORT BY THEMATIQUE PRIORITY
|
||||||
-----------------*/
|
-----------------*/
|
||||||
|
|
@ -137,21 +134,25 @@ SORT BY THEMATIQUE PRIORITY
|
||||||
// Fonction de comparaison pour trier par 'thematique_priority' utilisé par la fonction supérieur
|
// Fonction de comparaison pour trier par 'thematique_priority' utilisé par la fonction supérieur
|
||||||
function compareThematiquePriority($postA, $postB)
|
function compareThematiquePriority($postA, $postB)
|
||||||
{
|
{
|
||||||
|
|
||||||
$priorityA = $postA->thematique_priority ?? 0;
|
$priorityA = $postA->thematique_priority ?? 0;
|
||||||
$priorityB = $postB->thematique_priority ?? 0;
|
$priorityB = $postB->thematique_priority ?? 0;
|
||||||
|
|
||||||
$thematiqueA = getPostMainThematique($postA);
|
$thematiqueA = getPostMainThematique($postA);
|
||||||
$thematiqueB = getPostMainThematique($postB);
|
$thematiqueB = getPostMainThematique($postB);
|
||||||
|
|
||||||
|
$DocumentA = get_field('brochure_pdf', $postA->ID);
|
||||||
|
$DocumentB = get_field('brochure_pdf', $postB->ID);
|
||||||
|
|
||||||
|
$titleA = $DocumentA['title'] ?? null;
|
||||||
|
$titleB = $DocumentB['title'] ?? null;
|
||||||
|
|
||||||
|
|
||||||
write_log('############## post A');
|
|
||||||
// write_log($postA);
|
|
||||||
write_log("####" . $thematiqueA->name);
|
|
||||||
if ($priorityA == $priorityB && $thematiqueA->name != $thematiqueB->name) {
|
if ($priorityA == $priorityB && $thematiqueA->name != $thematiqueB->name) {
|
||||||
return strcmp($thematiqueA->name, $thematiqueB->name);
|
return strcmp($thematiqueA->name, $thematiqueB->name);
|
||||||
}
|
}
|
||||||
if ($priorityA == $priorityB && $thematiqueA->name == $thematiqueB->name) {
|
if ($priorityA == $priorityB && $thematiqueA->name == $thematiqueB->name && $titleA && $titleB) {
|
||||||
return strcmp($postA->title, $postB->title);
|
return strcmp($titleA, $titleB);
|
||||||
}
|
}
|
||||||
if ($priorityA < $priorityB) {
|
if ($priorityA < $priorityB) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -177,6 +178,7 @@ function sort_posts_per_thematiques_priority($postsQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------
|
/* -------------------------------------------
|
||||||
Build The page chaptering index
|
Build The page chaptering index
|
||||||
---------------------------------------------*/
|
---------------------------------------------*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user