Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Restaurant Menu Do I have a better way at populating a with menu items?
- This topic has 2 replies, 2 voices, and was last updated 7 years, 3 months ago by J. Davis.
- AuthorPosts
- June 12, 2017 at 7:53 pm #532434NoneGuest
I started learning WordPress less than two weeks ago and I’m experimenting with the ecosystem by creating a simple pizza restaurant website (which I may also decide to publish).
One of the pages of this site is intended to display a menu with a list of menu items (specifically: pizza name, list of ingredients and price). I wished to use a <table> and so I did.
Not having much experience with WordPress (and CMSs in general) I’m wondering if the solution I attempted is best than any other. Since I didn’t seem to find any APIs (both from WordPress and the Restaurant Menu plugin) I dug a little into the source code and, even more extensively, explored the structure of the MySQL database.
In short, my solution at creating a <table> in a page of the website and populating it can be summarized as follows:
- I created a custom template
page-menu-lb.php
in the folder of the child theme I had initiated earlier; - I inspected how the data inputted in the dashboard was stored in the database tables, and learned about the wpdb class for creating custom queries to the database;
- I created some
.php
files to query the database and store the collected data in an objected-oriented fashion. As I am dealing with pizzas, I created aPizza
class with the required attributes.
Now, the code required me more development time than I expected, but all in all it is working fine. What I’m rather more interested in knowing is: am I writing idiomatic code? Does the Menu Restaurant plugin allow to better integrate code such as this? I read about the suggestion of using actions and filters in this site, but I really didn’t find more documentation describing how to do that, and specifically for my case I don’t even know if that can help me.
Can you answer these questions, and possibly refer to the style adopted by WordPress and your plugin?
June 12, 2017 at 7:59 pm #532439NoneGuestIt seems like the site filtered out some of the characters in the title. It should read as:
Do I have a better way at populating a \<table\> with menu items?
June 20, 2017 at 2:49 pm #535718J. DavisKeymasterHi,
Thank you for clarification and sent example in a request. Doe to that example you can easily add custom styles to add borders to list view. You’ll get the same result.
Best regards,
John - I created a custom template
- AuthorPosts
- You must be logged in to reply to this topic.