Using WordPress public query variables

In simple words – it will tell wordpress what to query (to request a data from database). in all of cases it will try to search a posts (no mater post this or page or other post type) http://dmkim.ru/?s=uuu – eq search uuu on posts (default post type post & pages) and return a results … Read more

simple sql query on wp_postmeta very slow

wp_postmeta has inefficient indexes. The published table (see Wikipedia) is CREATE TABLE wp_postmeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, post_id bigint(20) unsigned NOT NULL DEFAULT ‘0’, meta_key varchar(255) DEFAULT NULL, meta_value longtext, PRIMARY KEY (meta_id), KEY post_id (post_id), KEY meta_key (meta_key) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; The problems: The AUTO_INCREMENT provides no benefit; in fact … Read more

what are the numbers between curly brackets in search query

Those are placeholders for % signs. If you’re sending % in the value to be compared against yourself, you’ll notice it transforming ‘%test%’ into wp_posts.post_title LIKE ‘{30d0e4b86a2a793010a75740f60810aff6b57f6d18edc10be7ca6dc158e40c06}\{30d0e4b86a2a793010a75740f60810aff6b57f6d18edc10be7ca6dc158e40c06}11{30d0e4b86a2a793010a75740f60810aff6b57f6d18edc10be7ca6dc158e40c06}\{30d0e4b86a2a793010a75740f60810aff6b57f6d18edc10be7ca6dc158e40c06}’ when you look at $query->request. The Query at the database side will have %. I haven’t looked into why exactly and where it is done, but I’ve noticed … Read more

Reversing the order of posts AFTER the query is performed

I figured out what I was doing wrong. A simple beginners mistake. Array_reverse was working properly, but I wasn’t then reassigning the reversed array back to the $home_shows WP_Query, hence not seeing any change. Here is the answer, and my revised code. <?php $args = array( ‘post_type’ => ‘show’, ‘posts_per_page’ => 5, ‘order’ => ‘DESC’, … Read more

Get Terms by IDs with IDs order

So I believe the question is how to get the terms back in the order of the Ids you’ve provided – which might not be sorted ascending or descending, but a random order instead. Surprisingly, I think there’s a shortcut for that in WP – who knew? This, I believe, is what you want to … Read more

How can I query all users who registered today?

Few months ago, I updated the Codex for get_users() and WP_User_Query, regarding the date_query support on the user’s registration date, in WordPress 4.1+. Then I also added a simple example on how to find users that registered during the last 12 hours. But the current question is how to find users that registered today. We … Read more

Get all image from single page using this query

Use get_children I used this code to extract all the images from a page gallery in the chosen order. you can include this code in the loop or use it stand alone. just choose the appropriate post_parent code (see bellow the code example). This example show all images associated to the page id 1, have … Read more

Is there a way of increasing the speed of this query?

We can do quite a lot to improve performance of your code. Lets set some benchmarks first BENCH MARKS I’m testing this with a category taxonomy term which has 9 posts and the post_tag taxonomy with 61 matching tags. With your current code, I get the following results 69 queries in =/- 0.4s That is … Read more