New answers tagged sql
For this I use WP-CLI because I find it the easiest and it takes care of serialized data. wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid There is also an option that writes your changes into an SQL file instead of manipulating the actual database: wp search-replace foo bar --export=database.sql
Sorry guys, just found the solution: SELECT p.post_name, t.name as clientName FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON ('p.ID' = tr.object_id) INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id) WHERE p.post_status = ...
For anyone else trying to find this: This can be done using the $parent parameter of get_comments. Here is the code assuming $parent_comment_id is the id of the parent comment. $childcomments = get_comments(array( 'post_id' => get_the_ID(), 'status' => 'approve', 'order' => 'DESC', 'parent' => ...
I know old, but I just fixed this! select * from wp_posts where id not in (select distinct post_id from wp_postmeta where meta_key='_your_meta_key') note (for efficient downvoters): please read the original posters question that he asked for "sql query", so stop downvoting something just coz you don't understand the questions requirements
WP_Query offers a date_query parameter, allowing you to set a range with before and after. $args = array( 'date_query' => array( array( 'after' => 'January 1st, 2015', 'before' => 'December 31st, 2015', 'inclusive' => true, ), ), ); $query = new WP_Query( $args ); For further ...
Try those args: 'date_query' => array( //start date array( 'year' => $startyear, 'month' => $startmonth, 'compare' => '>=' ), //end date array( 'year' => $endyear, 'month' => $endmonth, 'compare' => '<=' ) ),
Add this in your $args 'date_query' => array( array( 'after' => 'January 1st, 2015', 'before' => array( 'year' => 2016, 'month' => 1, 'day' => 1, ), 'inclusive' => true, ), ),
Firstly, as a PHP rule, you don't need to echo a variable when doing a string concatenation. Secondly, you need to prepare your query when adding a variable inside. So your query would become like this: $prepared = $wpdb->prepare( "SELECT meta_value FROM wp_woocommerce_order_itemmeta WHERE meta_key = '_wc_checkout_add_on_label' AND order_item_id = ...
Top 50 recent answers are included