How to save dynamically generated value in post type?
How to save dynamically generated value in post type?
How to save dynamically generated value in post type?
Where you put it depends, you likely want to put the get_post_meta() call: echo get_post_meta( get_the_ID(), ‘_custom_field’, true ) ); into the according template file. But of course you can also hook into a filter or action from your functions.php or a plugin.
Try this code: function postsCount($meta_value) { $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘custom_post_type’, // set you custom post type ‘meta_key’ => ‘project_select’, ‘meta_value’ => $meta_value, ); $my_posts = get_posts( $args ); $postsCount = count($my_posts); return $postsCount; } if ( is_user_logged_in() ) { echo postsCount(‘Draft’); echo postsCount(‘Completed’); } or if you want to get … Read more
You can use the transition_post_status action to manipulate the post content at the time when it is published. You just need to add a function like the one below into your theme or plugin: function post_published( $new_status, $old_status, $post ) { if ( $new_status == ‘publish’ && $old_status != $new_status) { //Do whatever you want … Read more
I believe if you specify ‘meta_key’ without a ‘meta_value’ it checks merely for the existence of the meta_key. I haven’t tried this but you might be able to specify a ‘meta_compare’ of ‘!=’ and some random value for ‘meta_value’ that you know would never actually be set as the value. $query->set( ‘meta_key’, ‘fieldA’ ); $query->set( … Read more
update_post_meta() not working in bulk option
The reverse mechanism should work. I assume you are trying the get post metadata with the post row. $resultat = mysqli_query($con,”SELECT * FROM wp_postmeta LEFT JOIN wp_post ON wp_postmeta.post_id = wp_post.ID WHERE wp_post.post_type=”shop_order””); However, there will be a lots of duplication. If one post have 100 metadata, you are also getting the post row 100 … Read more
In my case I use a custom query so I can just use: $query = new WP_Query(array(‘post_type’ => ‘akteur’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array(‘key’ => ‘wpcf-kurzbeschreibung’,’compare’ => ‘LIKE’,’value’ => $suchbegriff), array(‘key’ => ‘wpcf-zusatzinfo’,’compare’ => ‘LIKE’,’value’ => $suchbegriff) ) ));
Please check the callback function name for example add_action( ‘woocommerce_process_product_meta’, ‘new_metabox_save’,35 ); Function definiton function new_metabox_save(){ $post = get_post( $post_id ); }
how to echo/display the custom field value in specific custom field name?