Let current user know pending posts counts using wp_query

As others have already noted in the comments, using “posts_per_page” => 5, is better option than “posts_per_page” => -1, for your query as it will give you the information you need for your conditional check. Limiting what is queried is also something to consider – as honk31 mentioned. Along ‘fields’ => ‘ids’ you can also … Read more

How to Add text value in Automatically in this conditions?

This should work. Untested though. I don’t know how you get $woocomerce_wookc_text, but since you mentioned CMB, I am taking you are saving it as product meta data function wpse405916_add_to_cart( $cart_item_key, $product_id ) { //Get the woocomerce_wookc_text value. $woocomerce_wookc_text = get_post_meta( $product_id, ‘woocomerce_wookc_text ‘, true ); //Check if the value exists if ( $woocomerce_wookc_text && … Read more