our developers are telling us that we must create 1 template per category to achieve this scenario:
- we are creating dynamic product pages
- we have a separate app that stores all the product attributes including category
- the pages are dynamic, when they load they load the attributes from the app
this doesn't seem a big ask to us, but the developers are insistent. Should we challenge and how can we do so? (we do not have the technical knowledge).
We currently have 18 categories and the taxonomy is highly likely to change so we are worried this is not a robust or maintainable way forward.
our developers are telling us that we must create 1 template per category to achieve this scenario:
- we are creating dynamic product pages
- we have a separate app that stores all the product attributes including category
- the pages are dynamic, when they load they load the attributes from the app
this doesn't seem a big ask to us, but the developers are insistent. Should we challenge and how can we do so? (we do not have the technical knowledge).
We currently have 18 categories and the taxonomy is highly likely to change so we are worried this is not a robust or maintainable way forward.
Share Improve this question asked May 21, 2019 at 14:01 SiobhanSiobhan 11 Answer
Reset to default 0There can be multiple ways to achieve this, but creating a new template for each taxonomy/category is surely not the best.
I will achieve this with a single template by using these two methods,
You can pass the custom query variables while generating your dynamic pages or you can create a custom class that will loop through all categories, and adds additional variables as per the category. You can use is_tax() function with get_query_var() for this. Here you may be required to pass additional filter using add_filter( 'query_vars', 'function_name'); depending upon your post query.
Build a jQuery Ajax function and send your dynamically generated post loop results via wp_send_json().