From c0eb08661d3866ef412f15f66689d9d253b7bbdb Mon Sep 17 00:00:00 2001 From: Nonimart Date: Tue, 13 Jan 2026 14:55:09 +0100 Subject: [PATCH] FEATURE Reusing the component and now dynamicly filtering depending on post-type --- resources/js/filter-articles.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/filter-articles.ts b/resources/js/filter-articles.ts index c1dcf80..4a8f4ac 100644 --- a/resources/js/filter-articles.ts +++ b/resources/js/filter-articles.ts @@ -3,6 +3,7 @@ export default function filterArticlesInit() { if (!toolbar) return; const postGridToolbarActions = toolbar.querySelector('.post-grid__toolbar-actions'); + const currentPostType = postGridToolbarActions?.getAttribute('data-post-type') as string; const etiquettesSelect = toolbar.querySelector('select[name="etiquettes"]') as HTMLSelectElement; const auteursSelect = toolbar.querySelector('select[name="auteurs"]') as HTMLSelectElement; const sortBySelect = toolbar.querySelector('select[name="sort_by"]') as HTMLSelectElement; @@ -16,7 +17,7 @@ export default function filterArticlesInit() { try { const response = await fetch( - `/wp-json/dynamiques-datas/v1/build/articles?etiquette=${etiquetteValue}&auteur=${auteurValue}&sort_by=${sortByValue}&recherche=${rechercheValue}` + `/wp-json/dynamiques-datas/v1/build/${currentPostType}?etiquette=${etiquetteValue}&auteur=${auteurValue}&sort_by=${sortByValue}&recherche=${rechercheValue}` ); const data = await response.json(); console.log(data);