I am making an attempt to kind two cpt posts with term_order through the use of add_filter with posts_order hook. However plainly the second filter override the primary. How am i able to keep away from this ? Do I’ve to create customized posts_orderby hooks ? Thanks on your assist !
operate ts_sort_package_in_categorie($orderby, $question)
{
if (!ts_is_package_categorie_tax_query($question)) return;
international $wpdb;
return "{$wpdb->term_relationships}.term_order ASC";
}
add_filter('posts_orderby', 'ts_sort_package_in_categorie', 100, 2);
operate ts_is_package_categorie_tax_query($question)
{
if (empty($query->tax_query)) return;
if (empty($query->tax_query->queries)) return;
return in_array(
$query->tax_query->queries[0]['taxonomy'],
['package_categorie'],
true
);
}
and :
operate ts_sort_ticket_in_categorie($orderby, $question)
{
if (!ts_is_ticket_categorie_tax_query($question)) return;
international $wpdb;
return "{$wpdb->term_relationships}.term_order ASC";
}
add_filter('posts_orderby', 'ts_sort_ticket_in_categorie', 99, 2);
operate ts_is_ticket_categorie_tax_query($question)
{
if (empty($query->tax_query)) return;
if (empty($query->tax_query->queries)) return;
return in_array(
$query->tax_query->queries[0]['taxonomy'],
['ticket_categorie'],
true
);
}
I additionally tried one thing like this with no outcomes :
operate ts_sort_ticket_package_in_categorie($orderby, $question)
{
if (!ts_is_package_categorie_tax_query($question)) return;
international $wpdb;
return "{$wpdb->term_relationships}.term_order ASC";
if (!ts_is_ticket_categorie_tax_query($question)) return;
international $wpdb;
return "{$wpdb->term_relationships}.term_order ASC";
}
add_filter('posts_orderby', 'ts_sort_ticket_package_in_categorie', 99, 2);
operate ts_is_ticket_categorie_tax_query($question)
{
if (empty($query->tax_query)) return;
if (empty($query->tax_query->queries)) return;
return in_array(
$query->tax_query->queries[0]['taxonomy'],
['ticket_categorie'],
true
);
}
operate ts_is_package_categorie_tax_query($question)
{
if (empty($query->tax_query)) return;
if (empty($query->tax_query->queries)) return;
return in_array(
$query->tax_query->queries[0]['taxonomy'],
['package_categorie'],
true
);
}