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

How to get any tag ID

In your admin, go to Posts > Tags and then click edit for the tag you’re after – the URL in your browser address bar will look like: http://example.com/wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=X&post_type=post See the part where tag_ID=X – that X is your tag ID.

Get attached media only

All media (somewhat incorrectly) in the $wpdb->posts table will be “attachments” whether actually attached or not. “Attachments” that are actually attached will have a post_parent other than 0, so what you need are all of the attachments that have a 0 in the post_parent column, if I understand you. $args = array( ‘post_type’ => ‘attachment’, … Read more

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