admin管理员组文章数量:1391995
Lets say I have in my database a table for Universities - and for each entry in the database, the primary key would be the name of the University, i.e Duke.
If I created a template for all the university pages i.e university-template, is it possible to have an automatic routing to the specific universities page ( university-template updated with data from the database )?
i.e when someone accesses www.website/university/Duke the university-template is populated with the Duke entry from the database table. If the entry (in above examble, university/{slug}, slug is the entry to be searched) is not stored in the table then send the user to different custom template like uni-not-found-error-template.
Or do I need to create a page for each university ( like this question )
My current idea is to write a custom API that functions like so:
User sends GET request: GET www.website/university/Duke
University Table is queried for slug: Duke
If value error: send user to custom error page
If valid: pull template and fill corresponding Duke data from table
Display to page to User.
本文标签: custom post typesDatabase to page routing API
版权声明:本文标题:custom post types - Database to page routing API? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744619627a2615942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论