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.com/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.com/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.

  • Okay I am just seeing this question: wordpress.stackexchange.com/questions/334410/… will review and then update my question. – Adam Kit Mar 30 at 15:52
  • Yes but you would have to build all the routing querying and templating yourself. There's no special framework for dealing with custom tables you can plug into, any question would involve WP rewrite rules – Tom J Nowell Mar 30 at 16:19
  • Thanks @TomJNowell looks like I will get into the rewriting rules. – Adam Kit Mar 30 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.