How to query a staging database?
How to query a staging database?
How to query a staging database?
EDIT: I didn’t read your code properly, sorry! You’re using get posts which will only retrieve posts. To get all the images from the media library you’ll need to use WP_query. $query_images_args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ =>’image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => -1, ); $query_images = new WP_Query( $query_images_args ); $images = array(); … Read more
You haven’t mentioned what you want from this request and what is it for. You should clarify that to get the most accurate answer. Anyway, if you want to write a pure SQL request you can’t use WP_Query but need to use $wpdb->get_results instead, as mentionned by @hadimahoor. Here is a request to get a … Read more
Linking posts together with Advanced Custom Fields “both ways”
Query doesn’t display text data with apostrophes
The global $post; command acts similar to the_post() function, but outside the loop. When you want to use post’s data such as get_the_ID() or the_title() and you are not in the loop, you can use the global $post; to access these data. After so, you can have access to them, such as $post->ID or $post->post_title. … Read more
$id isn’t set anywhere in your code snippet. get_the_title( null ); returns an empty string. If you want the title of a post, you’ll need to set $id to a proper post ID. (Also, $args) is unset in the code you’ve posted, and I don’t see anywhere that you use query_contents either.)
First you need to loop trough the posts, get all the 10 posts, based on their sales number. Then, you need to check if the current product ID is equal to any ID of the products you looped. If it is, then you show ‘best seller’ tag for the product. In your code, you are … Read more
Speed up search query that searches in post meta?
get_users() is a convenience wrapper around WP_User_Query. Maybe you can use that directly, e.g. $user_search = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘meta_key’ => ‘last_login’, //’meta_value’ => ‘DATE_SUB(NOW(),INTERVAL 7 DAY)’, ‘meta_value’ => date(‘Y-m-d H:i’, strtotime(‘-7 days’)), ‘meta_compare’ => ‘<=’, ‘type’ => ‘DATE’, ), array( ‘meta_key’ => ’email_not_logged’, ‘meta_compare’ => ‘NOT EXISTS’, … Read more