Order Search Results Page by meta_value If no Value Return Remaining Results

You can accomplish this with multiple meta queries. $query->set( ‘meta_query’, [ ‘relation’ => ‘OR’, ‘wpcf-start-date’ => [ ‘key’ => ‘wpcf-start-date’, ‘compare’ => ‘EXISTS’, ], ‘no-start-date’ => [ ‘key’ => ‘wpcf-start-date’, ‘compare’ => ‘NOT EXISTS’ ], ] ); $query->set( ‘orderby’, ‘wpcf-start-date’ ); $query->set( ‘order’, ‘ASC’ ); This will tell WP to create a query that will … Read more

Is it possible to orderby multiple meta_keys when using meta_value_num?

You might want to check out the query improvements in WP 4.2 for ‘orderby’ and ‘meta_query’. Details are on https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query. Try to name your meta_query clauses, then order by them. Following code is untested: $query = array( ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘cat1-clause’ => array( ‘key’ => ‘cat1’, ‘type’ => ‘numeric’ … Read more

Get Recent Posts by Date in Multisite

Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent articles of all blogs (content aggregation) on display time since you have to query all blogs, sort the articles by date and display the ammount you need. Plugins like WordPress Post Indexer (https://premium.wpmudev.org/project/post-indexer) additional write all posts into … Read more

Add indexing to meta_value in wp_postmeta

Don’t limit the field, instead, limit the index, e.g. ALTER TABLE wp_postmeta ADD key(meta_value(100)) This limits the index to the first hundred bytes of meta_value. You’ll probably want an index on post_id, meta_key, meta_value for joins. How much of meta_key and meta_value is required depends on your data, for example ALTER TABLE wp_postmeta ADD key(post_id, … Read more

IP address character limit

You can filter ‘get_comment_author_IP’: add_filter( ‘get_comment_author_IP’, ‘wpse_77254_trim_comment_ip’ ); function wpse_77254_trim_comment_ip( $ip ) { return implode( ‘.’, array_slice(explode( ‘.’, $ip ), 2) ) . ‘…’; } Note this will fail with IPv6 addresses.

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