Fill empty custom field with other custom field

Assuming your products are custom posts you can do it like this: add_action(‘wp_insert_post’, ‘do_stuff’); // when product is created add_action(‘save_post’, ‘do_stuff’ ); // on product update function do_stuff( $post_id ) { // Making sure this runs only for products $slug = ‘product_post’; if ( $slug != $_POST[‘post_type’] ) { return; } if (!get_post_meta( $post_id, ‘new_price’, … Read more

Show related posts based of current ACF field name in a single page post (a loop within loop)

You don’t have a meta_value in your query. From your code I can’t tell what you’re doing with the meta values but you should be able to do this: // Store this BEFORE you go into the second loop. $category = get_field(‘category’); // The arguments for the second loop ‘post_type’ => ‘case-studies’, ‘showposts’ => 3, … Read more

Filtered by a custom field, ordered by another

You are sorting it incorrectly. You will need to check for artist-status meta key with meta_query and sort by last-name metakey. Here is your query. $args = array( ‘post_type’ => ‘artist’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘last-name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array ( array( ‘key’ => ‘artist-status’, ‘value’ => ‘invited’, ‘compare’ … Read more

Price comparison table based on Custom Post Type?

I suggest just making a new Post Type with the default WordPress register_post_type(). function create_my_post_type() { $labels = array( ‘name’ => __( ‘Providers pricing’, ‘myplugin_namespace’ ), ‘singular_name’ => __( ‘Provider pricing’, ‘myplugin_namespace’ ), ‘menu_name’ => __( ‘Provider Pricing’, ‘myplugin_namespace’ ), ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘description’ => __( ‘Pricing stuff … Read more