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 :
HELP ME
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 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');![]()
Partager