Press "Enter" to skip to content

WordPress Framework as a Web Application – Building a Simple Recipes Database

In the past, WordPress has evolved from a powerful blog system to a powerful CMS, and recently it has evolved into a powerful web application framework. In fact, with WordPress customizations and WordPress APIs, I can imagine that not many applications, you can't build. However, there are many applications that should not use WordPress builds. Choosing which framework to use (or choosing not to use a framework) is a balance between many advantages and disadvantages that affect architecture, performance, security, and scalability.

I have found WordPress to be very useful for medium-sized web applications without too much traffic. Building a small application from scratch, such as a restaurant table reservation system, or even a framework such as Rails or CakePHP, involves thinking about database schemas, controller structures, authentication, user interfaces, and so on. WordPress is already doing a lot of these things: You already have rough user management, an available management interface, and you only need to think about how to map the data model to an existing WordPress database structure.

Our Use Case: Recipe Database

Now, I would like to show you how to use WordPress to implement a simple recipe database. The requirements are very basic:

  1. allows recipes to be added and edited like regular posts or pages
  2. allows to classify recipes as healthy -> chicken -> marinated chicken breast
  3. allows to add ingredients to In recipes, ingredients recipes
  4. allow to add quantities in the recipe, for example 500ml milk, 20g sugar, 3 tablespoons olive oil

I will focus on how to customize WordPress to your data The model is adapted to show you how to use the basic elements to build each web application that supports WordPress:

  • Custom Article Type
  • Custom Category
  • Custom Field

[19659002] 19659002] In WordPress, the foundation of each content holding entity is an article. The two types of posts that you are familiar with are posts and pages. For our recipe database, we will create a new type: recipes.

register_post_type(' recdb_recipe';
) - array of tags (
' name 
"public ="=> true,
"Support' has_archive' 39; => arrays ("title", "editor", "#39; custom-fields ])

New post types will be displayed in posts and pages in the admin interface. It provides a field for the recipe title and provides a recipe description section An edit field. We even added support for custom fields, which will be needed later.

Set custom taxonomies for recipe categories and ingredients

In WordPress, taxonomies do not apply to save content, As posts, they are used to organize it.You should be accustomed to two default taxonomies: classification (layered) and labeling (without hierarchy). However, like postal types, you can add your own classifications for our recipes. number Libraries, you can use categories and tags, but they are really used to publish posts, so we create our own recipe categories and link them to recipe post types:

register_taxonomy (
' recdb_categories';
array(' recdb_recipe#),
" label> =>Recipe category'
' sort' => true,
"rewrite" => array (' => ' recipe class' '
' hierarchical structure ' => true,
' show_in_nav_menus' => true

In the admin interface, they will be displayed under the recipe menu and will be included in each recipe later A list of check boxes is displayed to classify them. They are the same as the ingredients we want, but they are slightly different: they do not have to be layered because each recipe has only a simple list of ingredients. Here's how to create a raw material taxonomy that will work like a normal tag. You can manage it from the admin interface and add it to any recipe:

' recdb_categories';
Array(' recdb_recipe'),
'sort'=> true,
"rewrite"#39 ; => array ('slug'=>'recipe-categories'),
"hierarchical"=> true,
"show_in_nav_menus" #39; => true

Setting Custom Fields for Deep-rooted Units

Now we can create new recipes, classify them and add ingredients. The last missing function is to add some amount of raw material because if you don't know how much food there is, then the information you need for milk when cooking your dinner is useless. Here is the custom field to enter the picture. For all ingredient labels to be added to the recipe, you must also add custom fields. The name of the field is always Quantity which will allow us to read them as arrays later. The value must be formatted as follows: taxonomy-term-slug:string . Here are some specific examples of custom fields on our recipes:

  1. Quantity -> Water: 100 ml
  2. Quantity -> Milk: 200 ml
  3. Quantity -> Sugar: 20 g

In your topic

I assume you have a work theme and now want to add a special template for the recipe. First add recipe categories to the menu. You are using custom menus that will be displayed in the menu editor just like the normal categories (you may have to activate them in the screen options panel). You should now be able to navigate to the recipe categories added on your site. The recipes included will appear with your index.php or other matching template.

The next step is to create a custom loop for recipes. We usually build a fairly regular loop, including the the_title and the_content template tags. However, building a list of ingredients is a bit special. To do this, we must first use get_post_meta to get the number of yuan values. Then, we cycle through the quantity, read the quantity and composition, and finally we provide a component link, which causes the site to list recipes with the same ingredients. Create a file named loop-recipes.php in your template directory and add the following loop:


    <? Php
    $ quantities = get_post_meta(get_the_ID(),"number");
    foreach($ quantity as $ quantity):
    $ quantity = explode(&# 39;:&#39;; $ quantity);? >

  • <a href =&#39; &#39;>

    <? Php
    ? >

    <? Php
    ? > <a href=" ">Reading recipes <? Php
    endif;? >

Now there are only loops embedded in the template files for recdb_categories and recdb_ingredients and adding templates to show the complete recipe. Create three files named taxonomy-recdb_categories.php, taxonomy-recdb_ingredients.php, and single-recdb_recipe.php in the templates directory. The following code enters the classification template:


List of recipes in the category

Code for the ingredients template here :

Formula list using

[1965902] Conclusions

If you followed all the steps, you should have a very basic but working recipe database running. Of course, from the user's point of view, adding ingredients is really scary, but this tutorial has nothing to do with usability. This is a starting point for anyone who wants to use WordPress as the basis for a web application that is not a blog or a regular website. I think it's important to really understand WordPress customizations and learn to map them to your own use cases.

Of course, there are some disadvantages to using WordPress for your web app, you shouldn't ignore them. However, once you decide to use WordPress, you will get a lot of cool features to defeat the disadvantages.

Business Credit: No Personal Credit And No Personal Guarantee Our Business Credit Membership Provides Weekly Training,resources,vendor Credit Lines, Cash Credit Sources And Banking Contacts. Brand New High Converting Self Help/wealth Generation Success Package. How To Buy Commercial Real Estate With No Cash And No Credit! Birddogbot - Real Estate Deal-finding Solution For Investors (view mobile)! Fan Victor - The Ultimate Fantasy Sports Plug-in (view mobile)! Get Lifetime Commission Per Customer! Our $1 Trial + Live Support Is Converting Like Crazy! Learn To Speak The Hebrew That Really Matters Using Sound, Video And Text. Recurring Charge! Legit Writing Jobs (view mobile)! Modern Love - Dating And Relationship / Get Your Ex Back (view mobile)! Next Generation Backlink Indexer. Own The Software That Takes Backlink Indexing To The Next Level With Our Brute Force Technology! Maitrisez Votre Acne Natural Treatment For Acne- Acne Treatment French Version. (view mobile) Membership Site For Learning Spray Paint Art. There Is A Thriving Community Of Street And Spray Paint Artists Online And In The World! Diy Car Painting Auto Body Course - Great For Automotive Male Traffic (view mobile) Astonishing Conversions On This New Online Dating For Women Program From Digital Romance. A Service That Every Homeowner Desperately Can Use: A Property Tax Assessment Review Service. Roofing Business Blueprint Uses The Latest Software & Marketing Tools Developed By Roofing Sales Training Expert David Deschaine! Discover How You Can Build A Complete Business Or Corporate Credit Profile In 90 Days! The Big Diabetes Lie - Real Dr Approved Diabetes Offer (view mobile) This Is An 11 Hour Video Course Teaching Guys How To Pick Up/date Women By Improving Their Communication Skills With Women! It's Never Been This Easy To Make Money Promoting Registry Cleaners! Instabuilder 2.0 - The Ultimate WordPress Marketing Plugin (view mobile)! Internet Jetset - Join The Internets Elite Group Of Middlemen (view mobile)! "#1 Stock Investing Club", Wealth Builders Club,monthly Commissions (view mobile)! Join The Live Stream Event From Anywhere On Any Device! Killer Conversions With 1 Click Recurring Billing Upsells For Max Earnings. The Millionaire Society Provides The Highest Quality Make Money Products Available! Lowest Refunds In The Market Because Customers Love This Product! Long Term Money Maker! Just Ask! Promote This, It Makes You Money! Put This Beast To Work For You On Lists Or Cold Traffic And Just Watch The Dollars Pile Up. New - Recurring Billing Front End! Huge Conversions (5%+ In Tests). 101 Toxic Food Ingredients - New Conversion Breakthrough! For Problem Drinkers. Enjoy A Strong Conversion Rate! Radical Inner Game - The Ultimate Seduction Product! hese Fun And Exciting Games Will Shoot Your Retention Rates Through The Roof! The Oxidized Cholesterol Strategy - Blue Heron Health News (view mobile)! Personal Trainers, Weightroom Instructors And Group Fitness Instructors Looking To Get Better Results With Injuries, Fitness Plateaus And Preventing Injuries! Self-esteem Elevation For Children Coaching Certification! Family Friendly Fat Burning Meals! A Lifetime Of Homework (view mobile)! Tacfit 26: New Generation. The Tactical Fitness Personal Gym System. (view mobile)! Reiki Healing Association Membership (view mobile)! Push Button Marketer - Automation Software For Internet Marketers! Biz Opportunity - Start Your Own Online Embroidery Business From Home (view mobile)! Gray Hair No More - Reverse Gray Hair - 2018 Update! Five Of The Top Converting Dating And Relationship Offers For Women! Pet Sitting Business Start Up Kit (view mobile)! Feel Tennis Online Video Instruction Courses (view mobile)! This Is A Sports Spread Betting Subscription Service That Generates Consistent Monthly Returns For Its Members! Pirate Ship Playhouse Plans (view mobile)! Sex Advice Education Programs By Gabrielle Moore! Robust 4-week Nutrition Education For Those Who Want To Quit Yo-yo Dieting And Learn How To Eat Healthy Forever! Fulfilling Relationships Course - Become Skilled (view mobile) 15-hour Video Course In Which You Learn 17 Relationship Skills To Create A Fulfilling Love Life, And Inspiring Friendships! Evergreen Web-store With 270+ Subliminal Mp3s In All Areas Of Self Improvement And The Law Of Attraction! Fearless Flow Conversation System! Full Shopping Cart- Brainwave Recordings, Health, Wealth, Prosperity, Manifestation, Success! Personal Development Offer: Killer Hook, Amazing Conversions! Push Button Marketer - Automation Software For Internet Marketers! Get Free Flights With Travel Hacking! 30-day Crash Course: Transgender Voice Feminization (view mobile)! Aquarius Man Secrets (view mobile)! How To Write Songs That Sell (view mobile)! Public Speaking Certification (view mobile)! Speak To Spark Arousal - For Men (view mobile) 5+ Hours Of Video Demonstration Modules That Help Men Start And Move Through Conversation With Ease!

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Mission News Theme by Compete Themes.