WP query taxonomy input differs to output?

A curious journey of a “cat“ Let’s assume we have the following category hierarchy: where the relevant rows from the wp_term_taxonomy table are: We want to query all posts in the animals category where the id is 65: $query = new WP_Query( array( ‘cat’ => 65 ) ); and try to understand why the resulting … Read more

Delete all posts from WordPress except latest X posts

The offset parameter is ignored with posts_per_page set to -1 in WP_Query. If you look at the source code in the WP_Query class, posts_per_page=-1 sets nopaging to true. if ( !isset($q[‘nopaging’]) ) { if ( $q[‘posts_per_page’] == -1 ) { $q[‘nopaging’] = true; } else { $q[‘nopaging’] = false; } } This in turn will … Read more

When tax_query used, results disappear (0 =1 produced)

tax_query takes an array of arrays. You have an array of arrays of arrays. var_dump($tax_queries); and will get this: array(1) { [0]=> array(1) { [0]=> array(3) { [“taxonomy”]=> string(15) “difficulty_mode” [“terms”]=> NULL [“field”]=> string(4) “slug” } } } Try it without the square brackets. That is turn this: $tax_queries[] = array( array ( ‘taxonomy’ => … Read more

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