Conditional sorting with variable using WP Query
You can put the condition in your select and then use that for sorting. SELECT ID, post_author = 6 as featured_author FROM wp_posts ORDER BY featured_author DESC, post_created DESC
You can put the condition in your select and then use that for sorting. SELECT ID, post_author = 6 as featured_author FROM wp_posts ORDER BY featured_author DESC, post_created DESC
What about changing BTC to a string <?php get_coin_price(‘BTC’); ?>
Going by the description for the $format argument An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. A format is one of ‘%d’, ‘%f’, ‘%s’ (integer, float, string). If omitted, all values in $data will be … Read more
wpdb detects the type of query and returns the result if it starts with select, else the affected rows. Since yours starts by call, it’s probably mistaking it for an insert, update, delete, etc. statement. Try this (might trick wpdb into thinking it’s a select statement: /* select */ call …; Or this (not sure … Read more
usually it because you are missing an “add_action” call for none logged in users. add this to your plugin or functions.php add_action(‘wp_ajax_nopriv_REPLACETHIS’, ‘ajax_get_date_post’); and change the REPLACETHIS to your action value from the ajax call. remember that when calling ajax from front-end and you want to allow none logged in users to make these calls … Read more
Your error message means that $wpdb in your code is currently pointing to a null pointer. Either WP is not loaded, or you’re missing a simple global $wpdb; statement, or both. If you need to load WP, include wp-load.php. Or better, in your JS, use ajaxurl: url = ajaxurl + ‘?action=youraction’ alongside (assuming the above … Read more
Simple and short: mysql_query() = Faster! $wpdb->get_results() = Safer! But in most cases since $wpdb is a global object and already in the memory using it will be be as fast as mysql_query(). Will this affect my performance? It can affect for better performance changes but they would be minor changes that its just not … Read more
First of all, you should look into using WP_Query for this: http://scribu.net/wordpress/advanced-metadata-queries.html Secondly, to see the results, just do a var_dump() before the return: echo ‘<pre>’; var_dump( $data );
Don’t bother using wpdb to update post content, use wp_update_post instead! http://codex.wordpress.org/Function_Reference/wp_update_post Instead of $wpdb->update($seo_tblPosts, array(‘post_content’=>$seo_pageContents), array(‘ID’=>$row_id)); Do: // Update post 37 $my_post = array(); $my_post[‘ID’] = $row_id; $my_post[‘post_content’] = $seo_pageContents; // Update the post into the database wp_update_post( $my_post ); As a side benefit it fires all the hooks so caching works as it … Read more
The code you’ve linked to above: //$sql set to raw SQL statement $sql = $wpdb->prepare($sql,$feed_id); if($wpdb->query($sql)){ $resp->uf_error = $wpdb->print_error(); } So if there isn’t, an error you try displaying the ‘error’ with $wpdb->print_error(). Also$wpdb->print_error() doesn’t return an error, it prints it. It’s (probably) the printing of that non-error that is causing an error in your … Read more