How to display child posts in the parent category

You need to use a tax_query with WP_Query. With a tax_query, by default, child terms are included to the term being set. Here is the example- $args = array( ‘post_type’ => ‘post’, // Your post type ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘rankk’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 100, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, … Read more

Display different number of posts from one category on the different pages

You can check for the existence of a variable, so you don’t overwrite it: add_action( ‘pre_get_posts’, ‘wpse7262_pre_get_posts’ ); function wpse7262_pre_get_posts( &$wp_query ) { if ( $wp_query->is_category() ) { if ( ! array_key_exists( ‘post_type’, $wp_query->query_vars ) ) { $wp_query->set( ‘post_type’, ‘game’ ); } if ( ! array_key_exists( ‘posts_per_page’, $wp_query->query_vars ) ) { $wp_query->set( ‘posts_per_page’, 9 ); … Read more

How to modify query so it grabs only 90 posts in total?

Try using paginate_links( $args ). Here is code adopted from codex. $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1; $args = array( ‘posts_per_page’ => 30, ‘paged’ => $paged, ); $the_query = new WP_Query( $args ); // the loop etc goes here.. $big = 999999999; echo paginate_links( array( ‘base’ … Read more

Order posts ascending with number in title

Old answer (which no longer works): A sneaky way to do it using MySQL, assuming the number’s always at the end, is to reverse the title, convert it to a number (+0), and then reverse again and convert it to a number: function wpse174646_posts_orderby( $orderby, $query ) { if ( $query->get( ‘orderby’ ) != ‘title_number’ … Read more

How to disable the editing of the time and date published?

There is no straightforward way to do this– at least not one that I see. That is, there don’t seem to be any hooks specifically intended for this task. You still have options though. This is what I’d do: First, deny changes. function deny_post_date_change( $data, $postarr ) { unset( $data[‘post_date’] ); unset( $data[‘post_date_gmt’] ); return … Read more

Sorting meta_value as integer doesn’t work

It’s not the plugin that is causing the issue it is the fact you are not querying the database correctly. It is not looking for integers your value is currently being stored as a string. To fix this you need to somehow change the value to a integer before it is passed to your array.

‘paged’ in wp_query doesn’t work

You set offset param, so paged param is ignored 😉 From Codex: offset (int) – number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged If you want to ignore most recent post in this query, you can achieve it in two ways. 1. Custom pagination. $ppp = get_option(‘posts_per_page’); … Read more