最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

templates - pass dynamic value to page to pull in categorised post cards

programmeradmin1浏览0评论

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 1
Add a comment  | 

1 Answer 1

Reset to default 0

There 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,

  1. 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.

  2. Build a jQuery Ajax function and send your dynamically generated post loop results via wp_send_json().

发布评论

评论列表(0)

  1. 暂无评论