How can I get a post field value using javascript?

Can I use the API and a JS ajax function to get the two values? Yes, absolutely. Step 1: (PHP) Registers the custom fields (i.e. add them to the WordPress REST API response for Posts) register_meta( ‘post’, ‘address1’, [ ‘type’ => ‘string’, // string/boolean/integer/number ‘single’ => true, ‘show_in_rest’ => true, ] ); register_meta( ‘post’, ‘address2’, … Read more

Get all Posts If has same custom field values in Posts

Following code will be proper for the meta query. $query_args = array( ‘post_type’ => ‘service’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘value’ => $zip, ‘compare’ => ‘LIKE’, ‘key’ => ‘zipcode’, ), ) ); $query = new WP_Query($query_args); <?php if ( $query->have_posts() ) :while ( $query->have_posts() ) : $query->the_post(); ?> <h3><?php the_title(); ?></h3> <?php endwhile; … Read more

Create a post in custom post type using field in registration form after users submit form

First, add the custom field to the registration form: add_action( ‘register_form’, function(){ ?> <p> <label for=”institute”>Institute</label> <input type=”text” name=”institute” class=”input” value=”” size=”25″> </p> <?php } ); Then, hook to user_register action which gets called after a user has been registered succesfully. add_action(‘user_register’,function($user_id){ $my_institute = array ( ‘post_type’ => ‘Institute’, ‘post_title’ => $_POST[‘institute’], // Custom field … Read more