wp_insert_post deleting previous post custom meta

SOLVED… for now I think this code was my problem: // use reset postdata to restore orginal query wp_reset_postdata(); if ( $current_slug == $approve_slug && $success === 1 && isset ($success) ) { $next_pay_stub_id = create_next_pay_stub( $term->term_id ); } } //this is the closing bracket of my foreach statement which I changed to if ( … Read more

Get WooCommerce product category list in functions.php

You need to use action to get categories. in init action you can get product categories. add_action(‘init’, ‘my_product_cat’); function my_product_cat() { $woo_cat_args = array( ‘taxonomy’ => ‘product_cat’, ‘orderby’ => ‘name’, ‘hide_empty’ => 0, ); $woo_categories = get_categories( $woo_cat_args ); echo “<pre>”; print_r($woo_categories); echo “</pre>”; }

Dont know why my custom post type not add_post_meta

In your second file Car_Data_Meta_Boxes_Init line: add_action( ‘save_car_data_meta’, array( $this, ‘save_meta_boxes’ ), 10, 1 ); you bind to your custom action save_car_data_meta but this action is triggered inside save_meta_boxes function this is why it never gets triggered unless you do var_dump(Car_Data_Meta_Box_Data::save_car_data_meta(158)); manual triggering of save meta function in metabox rendering logic. So you need to … Read more