Tracing the life of a query

Well you can try and run debug_backtrace(); on your function. For example: function wpse_82183_debug( $query ) { //your query goes here, this is just a basic one if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, 1 ); //magic happens here var_dump(debug_backtrace()); } } add_action( ‘pre_get_posts’, ‘wpse_82183_debug’ ); There are also a number of plugins … Read more

How to place a loop within another loop?

Try this: We declare an incrementer at the top of our outter loop called $popularLoop to keep track of how many popular loops we’ve been through, we assume we’re going to at least hit 1. Inside our Inner Loop (popular) we need to set how many posts per page we’re going to load, multiple that … Read more

WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given

I ran into this today. It’s a bug. I filed a bug report here: https://core.trac.wordpress.org/ticket/46797 The problem is this line of code: $qv[‘name’] = trim( $qv[‘name’] ); Source: https://github.com/WordPress/wordpress-develop/blob/a0ca5afd8977b5a3857084d9cb1bd345166e2f21/src/wp-includes/class-wp-query.php#L764 A (malicious) user sends a request that looks like: GET /?q=user/password&name[#post_render][]=passthru&name[#type]=markup&name[#markup]=echo ‘Vuln!! patch it Now!’ > vuln.htm; echo ‘Vuln!!’> sites/default/files/vuln.php; echo ‘Vuln!!’> vuln.php; cd sites/default/files/; echo … Read more

Is it possible to select against a post’s parent’s fields with WP_Query?

You should use posts_join and posts_where filters to modify JOIN and WHERE clauses. add_filter( ‘posts_join’ , ‘se333659_posts_join’, 20, 2 ); add_filter( ‘posts_where’ , ‘se333659_posts_where’, 20, 2 ); function se333659_posts_join( $join, $query ) { global $wpdb; if ( isset($query->query_vars[‘_rev_of_publ’]) && $query->query_vars[‘_rev_of_publ’] == ‘1’ ) { $join .= ” LEFT JOIN {$wpdb->posts} AS rev_p ON ({$wpdb->posts}.post_parent = … Read more

query_posts() in function makes global $wp_query out of sync?

Update with a better example header( ‘Content-Type: text/plain;charset=utf-8’ ); error_reporting( E_ALL | E_STRICT ); function failed_unset() { // Copy the variable to the local namespace. global $foo; // Change the value. $foo = 2; // Remove the variable. unset ( $foo ); } function successful_unset() { // Remove the global variable unset ( $GLOBALS[‘foo’] ); … Read more

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