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

custom post types - Database to page routing API?

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论