Indispensable MySQL queries for custom fields in WordPress

Download PDF

WordPress stores the data (articles, pages, categories, etc) in a MySQL database. It is therefore useful to know some codes to create a custom WordPress based website.

 

Note: This post includes MySQL queries for creating the custom fields in WordPress CMS (you can use for blog based design too). Before working in your database, take a backup first. You are responsible for your actions!

 

Disclaimers

 

Using phpMyAdmin

 

To run the applications listed here you should be able to log in to phpMyAdmin, a tool generally accessible from the administration of your host (via cPanel or Plesk for example).

Then go to the tab corresponding to the SQL database previously selected in the left side of the interface.

If you have never used phpMyAdmin, be careful!

 

Prefix Base wp_

 

For each of the queries below, remember to replace the prefix wp_ by one for your MySQL database.

It is highly likely that you do not keep the default prefix as recommended for safety reasons.

 

Backup your database

 

Before working in phpMyAdmin, backup your MySQL database.

 

Queries for custom fields

 

Add a custom field to all articles and pages

 

 

This adds a custom field (custom field) to all items in the database.

Consider replacing OwnCustomField by the name of the field in question and MyValue by the value of your choice.

 

Add a custom field in articles only

 

 

Same as above – with the same advice, but only for the blog articles (posts).

 

Add a custom field in pages only

 

 

Same as above – with the same advice, but only for pages.

 

Signature

Searched Terms:

indispensibe mysql querries, mysql copy cc field to category wordpress, update wp_postmeta meta_key
0saves

Here’s what we’ve got for you which might like :

Also, we have YouTube Videos and Apple iTunes Podcast Channel (the link will open iTunes App on Mac).

Additionally, performing a search on this website can help you.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Google+ or Twitter to join the conversation right now!

If you want to Advertise on our Article or want Business Partnership, you are invited to Contact us.

Contact Us