Strange problem with wp_get_attachment_image_src database (db) query count
Strange problem with wp_get_attachment_image_src database (db) query count
Strange problem with wp_get_attachment_image_src database (db) query count
You can still do the AS with $wpdb, I find it still makes stuff look cleaner. You can use the $wpdb->prepare() method for sanitation. Are you looking for something like this? function combined_downloads($post_id) { global $wpdb; return $wpdb->get_var($wpdb->prepare( “SELECT SUM( meta_value ) FROM $wpdb->postmeta AS m LEFT JOIN $wpdb->posts AS p ON m.post_id = p.ID … Read more
Found the problem. In my args, I should have included this line: ‘post_type’ => array( ‘one’, ‘two’, ‘three’, ‘four’, ‘five’, ‘six’ ), above the ‘tag’ arguments
Query for distance OR taxonomy term
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
The problem was due to the fact that the query was restructured in this latest update. As pointed out by d79 in this question, the query changed from: SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_users.* FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) INNER JOIN wp_usermeta AS mt1 ON ( wp_users.ID = mt1.user_id ) WHERE … Read more
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
Try changing the field value to term_id, since there is no id value for that option. Ref: WP_Query Taxonomy Parameters
NOTE: This code is correct above is the solution I was looking for. I just overlooked applying it to some scripts and so I thought it wasn’t working.
As @s_ha_dum already pointed out, you can use the built-in private posts status function when publishing posts. This will hide these posts from all logged out users. As you have already gone down the custom fields route, you can make the following changes to your custom post type archive Remove your custom query. This messes … Read more