Meta key in wp_query bug?
You must add meta_key to your array. How else the query will know what meta value to use? Try adding ‘meta_key’ => ‘your_key’
You must add meta_key to your array. How else the query will know what meta value to use? Try adding ‘meta_key’ => ‘your_key’
First of all, you didn’t say if you’ve done this or not, but you will need to create your products in Stripe. Then, when you are ready to bill your customer, you simply create a new order (or if you want to keep orders in Stripe separate like in your WP system, one order per … Read more
Try below code global $wpdb; $result = $wpdb->get_results($wpdb->prepare(“SELECT * FROM TABLE_NAME)); Replace TABLE_NAME with your custom table name.
I managed to achieve what I wanted by piping wp-cli with xargs and grep, like this: wp post list –post_type=CPTNAME –field=ID | xargs -n 1 wp post meta list –format=csv | grep -E “^[[:digit:]]*,(CUSTOMFIELD1|CUSTOMFIELD2|…|CUSTOMFIELDN)” >> file.csv This is, however, extremely slow, taking more than 30 minutes for 10 thousand CPTs. I think a direct SQL … Read more
For future reference on this question. I solved my problem by updating my save routine to save each field to its own key. This does work much better since each fields is saved to its own corresponding key it makes retrieval from WP_Query much better /* check if this is an autosave and if YES … Read more
get_post_meta() calls get_metadata(), the parameter description of which says: $single (bool) (Optional) If true, return only the first value of the specified meta_key. This parameter has no effect if meta_key is not specified. Default value: false So, since you are passing ” as the meta_key, the $single parameter is ignored. Does that explain it? Edit: … Read more
You need to use save_post action along with wp_insert_post() function for this. Something like following may work. function tnc_update_car_details( $post_id, $post, $update ) { // If this is a revision, don’t continue if ( wp_is_post_revision( $post_id ) ) return; $post_type = get_post_type($post_id); // If this is not an invoice post type, don’t continue if($post_type !== … Read more
The below should loop your post types and only insert the header once if it has a post for that post type. I am sure there is a lot better ways to code this cleaner but this should work * I have not tested only coded in this page. I am not sure about the … Read more
Take a look at the documentation for register_uninstall_hook. There is as well a register_deactivation_hook function which can be usefull as well. You could use them for calling a function which will remove the data from DB. But you should be careful and maybe let user check a checkbox to do so.
You should use WordPress conditionals to determine which page you’re on, build the title based on that, then print the title. <?php $sep = ‘ | ‘; $name = get_bloginfo( ‘name’ ); if( is_home() || is_front_page() ) $title = $name . $sep . get_bloginfo( ‘description’ ); if( is_single() || is_page() ) $title = wp_title( $sep, … Read more