Woocommerce frontend edit custom fields

you don’t have to edit the order-details.php page the woocommerce_order_details_after_order_table action will achieve the same results. add_action( ‘woocommerce_order_details_after_order_table’, ‘namespace\custom_field_display_cust_order_meta’, 10, 1 ); function custom_field_display_cust_order_meta( $order ) { echo ‘<form [whatever]>’; /* translators: whatever */ echo ‘<p>’ . sprintf( __( ‘<strong>Property 1:</strong> %1$s (%2$s)’ ), ‘<input [whatever]>’ . get_post_meta( $order->get_order_number(), ‘property 1.1’, true ) . ‘</input>’, … Read more

`update_post_meta` not working anymore

get_the_ID() is a “Loop” function. It won’t outside the Loop, and there is not Loop in your code. Essentially, you are passing a bad ID to the function causing it to fail. If you had debugging enabled you might see feedback to that effect. You are also using a variable– $dateStart— that is not set … Read more

Convert all dates stored in custom field

Find the correct key for game_date_key and run this once: global $wpdb; $posts = $wpdb->get_results(“SELECT ID FROM “.$wpdb->prefix.”posts” WHERE post_type=”post”); foreach ($posts as $post) { $old_date = get_post_meta($post->ID,’game_date_key’,true); $new_date = date(‘d/m/Y’, strtotime($old_date)); update_post_meta($post->ID,’game_date_key’,$new_date,$old_date); } (I assume you will have the sense to backup your database first just in case. 🙂

How add body_class from wp_termmeta

First check it is product category archive page using is_tax Then use get queried object_id to get the current term ID Then after you can use get_term_meta to get class name. Example: add_filter( ‘body_class’, ‘lalka_custom_taxonomy_in_body_class’ ); function lalka_custom_taxonomy_in_body_class( $classes ){ if (is_tax(‘product_cat’)) { $custom_class = !empty( get_queried_object_id() ) ? get_term_meta(get_queried_object_id(), ‘custom-class’, true) : FALSE; if … Read more

Group by custom field value (start and end times)

try this wich first stack all posts with same times $tabEvent = []; foreach ( $rand_posts as $post ) { setup_postdata( $post ); $start_time = get_field(“start_time”); $end_time = get_field(“end_time”); $index = “$start_time|$end_time”; // store all the posts with same times if (!isset($tabEvent[$index])) { $tabEvent[$index] = []; } $tabEvent[$index][] = $post; } foreach ($tabEvent as $index … Read more

Edit custom fields in posts list

Yes, you can use Admin Columns Pro (paid plugin with free version) to use inline edit for custom fields columns just from the WordPress posts list. It even comes with sorting and filtering for columns. You can easily add new columns with this plugin. https://www.admincolumns.com/ There are also plugins that allows you to bulk edit … Read more

Custom post type name and assigning custom taxonomy

I’ve checked another option and asigned my custom taxonomy to custom post type using its name but without capitals and space. ‘postname’ works with original ‘Post Name’ So for custom post type register_post_type( ‘Post Name’, $args ); I can use register_taxonomy( ‘custom taxonomy’, array( ‘postname’ ), $args ); And it works.