How to query custom post type one after another

Since version 4.0 is available ‘type’ option for ‘orderby’ argument in WP_Query. Also, thanks to the more powerful ORDER BY in WordPress 4.0 you can control how posts of a post type are ordered. Example (untested): $q = new WP_Query(array( ‘post_type’ => array(‘map’,’item’), ‘orderby’ => array( ‘type’ => ‘DESC’, ‘title’ => ‘ASC’ ) ));

Sorting of coupons in the right way

Note that this part: ‘post_status’ => ‘published’, should be: ‘post_status’ => ‘publish’, You can then try the following: $args = array( ‘post_type’ => ‘gutschein’, ‘pagination’ => true, ‘posts_per_page’ => ’10’, ‘posts_per_archive_page’ => ’10’, ‘ignore_sticky_posts’ => false, ‘post_status’ => ‘publish’, ‘paged’ => $paged, ‘meta_key’ => ‘unixendet’, ); add_filter( ‘posts_orderby’, ’emti_orderby’ ); $q = new WP_Query( $args … Read more

How can I display a number to represent the order of post?

The global $wp_query (in this case its the $query var) holds the $current_post which is available in the loop and tells the index of the current post ( $wp_query->current_post ). The $wp_query->post_count tells the number of posts being displayed in the loop, and this actually becomes a simple arithmetic solution that will work no matter … Read more

Display list of most recent grandchild (third tier) pages

The only (easy) way this can be done is to query all special, calculate their depth, and then build a new stack of 3-level deep: $grandkids = array(); $specials = get_posts( array( ‘posts_per_page’ => -1, ‘order’ => ‘DESC’, ) ); foreach ( $specials as $special ) { if ( count( get_post_ancestors( $special ) ) === … Read more

Display Upload Author & Get Uploaded Post ID

Attachments count as a built-in post type which is extremely similar to Posts and Pages. The field you’re looking for is post_author. If you have an attachment object: $attachment->post_author If you only have the attachment ID you can use get_post_field( $attachment_id, ‘post_author ); To get the actual Post the the attachment was originally uploaded to … Read more

Why the pre_get_posts hook can cause apache stopped working?

As per this WPSE thread you are actually putting overload to the apache. That’s why it’s reacting like that. 🙂 So let’s cut the overload, use is_main_query() properly, and just add a simple conditional to your pre_get_posts hooked function: function e_exclude_posts( $query ) { if( !is_admin() && $query->is_main_query() && $query->is_tax(‘my_tax’) ) { $expired = g_get_all_the_expired_posts(); … Read more

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