FEATURE Reusing the component and now dynamicly filtering depending on post-type
This commit is contained in:
parent
f8b804e991
commit
c0eb08661d
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user