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.

How to uniquely identify queries?

tl;dr: build affordable unique identifiers for queries is possible, but is pretty useless. If you’re looking for unique identifiers for query objects, then you can use spl_object_hash, but IMHO is pretty useless: it is non-predictable, and also you get different id even if query vars are identical, but set on 2 different query objects. Only … Read more

Combining two wordpress queries with pagination is not working

You can try the following (untested): Setup the query arguments #1: (today) //—————– // Query part #1: //—————– $args1 = array( ‘post_type’ => ‘post’, ‘orderby’ => ‘comment_count’, ‘ignore_sticky_posts’ => 1, ‘date_query’ => array( array( ‘after’ => date(‘Y-m-d’), ), ‘inclusive’ => true, ) ); Setup the query arguments #2: (!today) //—————– // Query part #2: //—————– … Read more

tech