Supposing that each food item is treated as a post (perhaps even a custom post type), and the parameters (name/calories/etc.) are attributes of this post, you would do well to treat them as post meta fields.
Various means exist to grant end-users the ability to maintain custom fields; my preferred option is Developer’s Custom Fields, but other solutions exist. Regardless of the method used, the assumption is that for a given post certain meta fields have been populated and must be queried at runtime.
Within a loop (in particular, after invoking the_post()
), and for a particular custom field (for illustration I will use “calories”), you would retrieve the value using get_post_meta()
as shown below:
echo "Calories: " . get_post_meta(get_the_ID(), "calories", true);
Some assumptions are made here (that you’re in a page/post loop, the data you are requesting has already been entered, and the name of your custom field is “calories”).