Order Posts by Closest Numeric Values

One possibility is a direct SQL query similar to the one given here. But I’m not convinced that it would be much more efficient than 2 queries, all handled by WordPress: The is untested $price =0; //Price of current property $id=0; //Property (post) ID. $args = array( ‘post_type’ => ‘property’, ‘post__not_in’=>array($id), ‘posts_per_page’=> 2, ‘meta_query’ => … Read more

BP Multi Network & Members Directory [closed]

You can filter the members loop in BuddyPress by meta values for the members. So you would need to change the loop in the template file members/members-loop.php to be: <?php // Getting current blog_id global $wpdb, $current_blog; $id = $current_blog->blog_id; // Setting variable for current blog_prefix $blog_prefix = $wpdb->get_blog_prefix( $id ); // Start the BuddyPress … Read more

get data from wp-query, outside the loop & without url change

It sounds like you’re looking for wp_localize_script() which lets you pass data to a script that is already enqueued. It works roughly like this: <?php // assuming your script is already registered wp_enqueue_script( ‘wpse_81817’ ); // Do the array building of terms you plan on doing $wpse_81817_phpdata = array( ‘myKey’ => ‘a value’ ); // … Read more

Query meta field using between

Your problem is this: CAST(wp_postmeta.meta_value AS SIGNED) Run a simple SQL query (command line or PhpMyAdmin, whatever you like) like SELECT CAST(‘1.2’ as SIGNED) and you will see that the value returned is 1. What causes that cast is ‘type’ => ‘NUMERIC’,. You can pass DECIMAL to meta_query instead of NUMERIC but I don’t see … Read more

Query by meta_key and order by meta_value_num return orderby date

The problem in your code is ‘meta_query’ code is write insde array of array $args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘participant’, ‘order’ => ‘DESC’, ‘meta_key’ => ‘participant_partage_class’, ‘orderby’ => ‘meta_value_num, ‘meta_query’ => array(array( ‘key’ => ‘participant_partage_class’, ‘type’ => ‘SIGNED’, ‘compare’ => ‘>’, )), ‘posts_per_page’ => ‘8’, ‘paged’ => $paged ); $query = new … Read more

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