ORDER BY custom field value out of where clause

Define that a population has to be set, and make a list of allowed states as an array. Afterwards, take population into the orderby and sort it DESC. $q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => array( ‘Wisconsin’, ‘California’ ), //allowed values ‘compare’ => … Read more

Display post from a date range from custom field

The magic parameter ist described at WP_Query under: Custom Field Parameters You need to add a meta_query array to your $args where you define your range. In your case the code could look like this: $range = array( ‘2015-05-01’, ‘2015-05-31’, ); $args = array( ‘post_type’ => ‘score_post_type’, ‘posts_per_page’ => 5, ‘meta_key’ => ‘score_time’, ‘orderby’ => … Read more

How to make a customized user registration form using the built in wp-register() template tag

The Codex has an article that outlines how to do this: https://codex.wordpress.org/Customizing_the_Registration_Form It even provides an example: //1. Add a new form element… add_action( ‘register_form’, ‘myplugin_register_form’ ); function myplugin_register_form() { $first_name = ( ! empty( $_POST[‘first_name’] ) ) ? trim( $_POST[‘first_name’] ) : ”; ?> <p> <label for=”first_name”><?php _e( ‘First Name’, ‘mydomain’ ) ?><br /> … Read more

How to display custom field in woocommerce email orders? [closed]

If the code you have provided is the only code you are using to achieve what you want then thats incomplete code. Below is the tested version of code which works well. I hope this helps: /* Add the field to the checkout */ add_action(‘woocommerce_after_order_notes’, ‘my_custom_checkout_field’); function my_custom_checkout_field( $checkout ) { echo ‘<div id=”my_custom_checkout_field”><h3>’.__(‘My Field’).'</h3>’; … Read more

WP REST API – get custom taxonomies based on terms & filter

Herewith find the below answer for my own question for the custom taxonomies based listing the categories add_action( ‘init’, ‘rest_custom_category_request’, 25); function rest_property_type_category_request(){ global $wp_taxonomies; $wp_taxonomies[‘custom_category’]->show_in_rest = true; $wp_taxonomies[‘custom_category’]->rest_base=”custom_category”; $wp_taxonomies[‘custom_category’]->rest_controller_class=”WP_REST_Terms_Controller”; } Answer for the filter with custom meta key & values add_filter(‘rest_query_vars’, ‘custom_rest_query_vars’); function custom_rest_query_vars($query_vars) { //print_r($query_vars);exit; $query_vars = array_merge( $query_vars, array(‘meta_key’, ‘meta_value’, ‘meta_compare’) ); … Read more