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

Sort posts by Date (DESC) and by Title (ASC)

You can pass an array to the query as the following example described in the Codex shows: $args = array( ‘orderby’ => array( ‘title’ => ‘DESC’, ‘menu_order’ => ‘ASC’ ) ); $query = new WP_Query( $args ); In your case will be something like this: /* Order Posts Alphabetically */ function prefix_modify_query_order( $query ) { … Read more

Custom Search Query

1) You can use the template search.php and searchform.php as your starting points. Creating a Search Page Codex 2) As far as the custom query goes, you can use pre_get_posts hook to test if you’re on a search page, then you get $_GET your values, edit your query accordingly. Action Reference – pre_get_posts There are … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)