Customize any WordPress, add new custom post type, meta query, lookup

in order to customize any WordPress theme you need to have a wordpress installation and two plugins, for the first part we recommend greenbackend wordpress solution which will handle any WordPress website with all the different needs and capabilities, we recommend the Unlimited and Business Geko Pro wordpress hosting, you could check them here

Additionally, We need the following two plugins to manage the database and the UI:
1-Custom Post Type UI By WebDevStudios – link
2-Advanced Custom Fields By Elliot Condon – link

These two plugins are used to create new entities such as database tables and fields or columns, since WordPress is an EAV framework it uses WordPress tables and meta table to create the tables and the columns.

In this scenario, We will create a program table ” in WordPress we call it a program custom post type“.

1-program custom post type

2- After saving the program custom post type you will see it under the main menu with the given cpt properties

3- We need to add extra columns to the program post type

Logo – Image Field, it got Image URL in its return format
ٍSummary – Text Area
Gallery – Post object to load a woo commerce product and its images, Filter used is Product, return format is Post Object
facebook – Text Field, to store social profile link

Note: Its important to map the current field to be within the Location of Program, so Post type shoud be “is equal to” “Program” inside the Location Rules.

4- Save the field and open new or edit program screen you will see the following, just assign the product and different items to the program and you are done

In the previous links we’ve seen how to link program with other objects such as product, such that each program might have a product item, but some times a program might have many news, many events or activities, in this case we need to link the news item or event item with the program it self, this relation is called 1 to many whereas the program to product relation is called one to one.

5- in order to create the one to many relationship in WordPress we have to navigate to many and add it to one like the following:

The same rule applied for the events.

6- Link many to one, simply navigate to any post and link it with the program field and you are done.

You did a great job in the previous steps, now its time to make a page inside the theme and display the related fields, we will leave you a code snippets from the program template inside the theme:

1- Create a file named – single-program.php

2- Insert the following script to view the program

Note: You might have noticed that we used “icl_t” which indicates that we’ve used a translatable WordPress strings, you could checkout in this link here a complete example how to use localizable strings within WordPress and wpml.

Wow, you did it, if you feel this lesson was helpful give us a message thru whats-app also you could give us a donation on Paypal at if you wish to see more free posts like these in the future.

Thanks for viewing this! <3 -Ahmad Naser