Bonjour, je cherche à faire un seul archive layout pour chacune de mes catégories de produits (c’est un CPT classique, on utilise pas woocommerce).
Malgré mes tentatives, je n’arrive pas à assigner correctement le layout pour qu’il s’applique simplement à chacune des catégories "corbeilles, paniers…). J’ai donc bidouillé un peu pour faire ma propre requête et ça fonctionne.
Mais j’ai besoin d’implémenter de la pagination et je sais que celle-ci ne fonctionne pas avec les query personnalisées. Pourriez-vous m’aider à configurer correctement ce layout pour toutes les catégories de produits spécifiquement ?
Hi @deciplex,
Thanks for reaching out.
I have checked and used the Product Category condition to match the specific category, and it worked correctly as expected.
Can you please explain a bit more what exact problem you were having with that? It will help us to recognize the issue. Any screencasting video helps more.
Thanks
le looper provider personnalisé que j’avais mis en place était encore actif… Quand je désactive le looper provider et que j’utilise vos réglages, aucun produit n’est affiché et je n’ai pas non plus la pagination. Je joins une vidéo en note privée
Hi @deciplex,
When you are assigning the condition to the specific category, it will pull the products/ posts from that specific category. I have checked and found there is no product assigned to that category.
Also, it seems that you are using the Pagination element within the Looper. Please remember that the pagination works only with a few Pre-defined archive layouts. I suggest you use any of the Pre-Defined Archive Layouts and check if the pagination works. If that works, I suggest you change the structure and style to match your design.
Alternatively, you can find the way to create the pagination within the Looper Provider using the Twig described in the following threads.
I have created a Sample Archive Layout with the predefined templates and assigned a product to the specific category, and found that it is showing. You can use the sample layout and change it according to your design.
Hope it helps.
Thanks
Ah! je pensais que le champs taxonomy de mon ACF “produit” était suffisant… Mais en effet je comprends mieux. Merci beaucoup!!!
Pour info, comme je souhaite conserver ce champ ACF pour faciliter la gestion côté client, j’ai ajouté une petite fonction qui synchronise automatiquement les catégories ACF avec les catégories natives WordPress. Le but est de conserver une interface ACF tout en assurant le bon fonctionnement des archives.
add_action(‘acf/save_post’, function($post_id) {
if (get_post_type($post_id) !== ‘produit’ || !is_numeric($post_id)) return;
if (isset($_POST[‘acf’][‘field_6880b4c6df4e7’])) {
$terms = array_map(‘intval’, $_POST[‘acf’][‘field_6880b4c6df4e7’]);
wp_set_object_terms($post_id, $terms, ‘categorie-produit’, false);
}
}, 20);