SQL delete orphaned post meta data

When using lots of plugins and different themes or when testing your own custom made theme or plugin, a lot of post meta can remain in your database that is not linked to a post. By applying the following query to your database, you can delete all meta data that is no longer linked to […]

SQL query to add post meta for each WordPress post

To add post meta to all posts (posts with post type “post”) in your WordPress database you should use the following SQL query: To add post meta to another post type, simply change the post type in the WHERE clause.

Extending admin search with post meta

The default search functionality in your WordPress admin is not based on post meta. To be able to search by post meta you need to extend the posts_join and posts_where query functions by adding a filter on both. First I will add the filter for posts_join as follows: Then I add the filter for posts_where: You can add these […]

Extend search with predefined search query strings

Almost every WordPress developer had some annoyance with the basic search functionality of WordPress. Today I customised the search functionality for one of my projects so I am able to add a list of comma separated search query strings to a post where I want it to be found on. So for example a product like “bicycle” needs to […]