I am learning Wordpress for the first time since a couple weeks or so, and to make practice and create something useful, I've started a pizza restaurant website, which perhaps I'll also publish.
To explain myself in the shortest possible way, I'm currently editing some of the default MotoPress Restaurant Menu plugin templates to make the site look like I'd want. First, the plugin offered a menu listing template, but I had no idea on how to sort the elements, how to filter them, and how to achieve a table-like display instead of a list of <div>
s inside the page. What I did to "improve" this template was creating a custom page-menu-lb.php
template file and adding there code for populating a <table>
with data from the database.
To fetch the data from the database, instead, I created some files and classes which use Wordpress API function/classes like WP_Query
and the (wp)_get_*
functions; further, I also modelled a Pizza
class to store data in an object-oriented way. With this, I was able to construct a menu page the way I intended.
Now that I also have to display posts for single items (in my case, pizzas) I have to modify other template files of the kind single-{post-type}.php
. I know more than a couple of ways to do it, but what is the most idiomatic and "correct" in Wordpress?
My two final questions are therefore:
- How should I fetch the data from the database? I saw that internally the plugin does it by calling its own functions - it has a kind of little framework inside. Should I use them, or do I risk upgrades incompatibilities? Or should I limit myself to querying the database by using the
WP_Query
,wpdb
classes and the(wp)_get_*
functions? - Should I modify the plugin default templates by implementing action and filter hooks as recommended by the succinct plugin documentation, or create custom templates?