jakemackie / wordpress

A full stack web social platform as a way of learning Wordpress
2 stars 0 forks source link

Database class to connect and make modular queries 🔍 #16

Closed callumholloway closed 2 weeks ago

callumholloway commented 3 weeks ago

Noticed you had this in your Readme.md. You probably won't need to actually do anything with this, there is a prebuilt WordPress class that you should be able to use to get anything you need in terms of querying post data.

https://developer.wordpress.org/reference/classes/wp_query/

^ We use this very very heavily

In terms of other pieces of data, there's loads of prebuilt WP functionality that can grab probably anything you need from the db. Eg if you want to get a piece of postmeta there's a function... https://developer.wordpress.org/reference/functions/get_post_meta/

equally with update, delete, add...

alfiephillips commented 3 weeks ago

Very useful thank you. I believe I used wp_query in the challenges; much better than setting up an external connection to the database when we can use that 👍