8768 sujets

Développement web côté serveur, CMS

Bonjour à tous,
Je me suis créé un CPT 'bière' avec une taxonomy 'gamme' et j'aimerai que quand je suis sur ma fiche bière, que je clic sur les flèches de navigations (next_post_link et previous_post_link), que la navigation soit filtré par rapport à ma gamme (ce que j'arrive déjà à faire) mais également par rapport à une meta_key '_position'.
Voilà la page en question :
https://biereratz.n12404.com/bieres/?ancre=speciales
Et voici mon bout de code :

function get_adjacent_past_biere_join($join)
{
    if (is_singular('biere')) {
        global $wpdb;
        $new_join = $join . "LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id ";
        return $new_join;
    }
    return $join;
}
add_filter('get_previous_post_join', 'get_adjacent_past_biere_join');
add_filter('get_next_post_join', 'get_adjacent_past_biere_join');

function get_prev_past_biere_where($where)
{
    if (is_singular('biere')) {
        global $wpdb, $post;
        $id = $post->ID;
        $new_where = "WHERE p.post_type = 'biere' AND p.post_status = 'publish' AND m.meta_key = '_position'";
        return $new_where;
    }
    return $where;
}
add_filter('get_previous_post_where', 'get_prev_past_biere_where');

function get_next_past_biere_where($where)
{
    if (is_singular('biere')) {
        global $wpdb, $post;
        $id = $post->ID;
        $new_where = "WHERE p.post_type = 'biere' AND p.post_status = 'publish' AND m.meta_key = '_position'";
        return $new_where;
    }
    return $where;
}
add_filter('get_next_post_where', 'get_next_past_biere_where');

function get_prev_past_biere_sort($sort)
{
    if (is_singular('biere')) {
        global $wpdb;
        $new_sort = " GROUP BY p.ID ORDER BY m.meta_value DESC";
        return $new_sort;
    }
    return $sort;
}
add_filter('get_previous_post_sort', 'get_prev_past_biere_sort');

function get_next_past_biere_sort($sort)
{
    if (is_singular('biere')) {
        global $wpdb;
        $new_sort = " GROUP BY p.ID ORDER BY m.meta_value ASC";
        return $new_sort;
    }
    return $sort;
}
add_filter('get_next_post_sort', 'get_next_past_biere_sort');

HELP ME Smiley scream