Filtering output by two custom fields using posts_where and add_rewrite_rule
Filtering output by two custom fields using posts_where and add_rewrite_rule
Filtering output by two custom fields using posts_where and add_rewrite_rule
In order for sorting by a meta value to work, the meta_key parameter is required (source): Note that a meta_key=keyname must also be present in the query. Unfortunately this will result in only posts with the meta key set to be found by the query. From here there are two options: Use a query to … Read more
You have to add following code after your code to get the dates sorting correctly. It’s working correctly for me. Hope it will help. function change_user_order( $args ){ if( isset( $args[‘orderby’] ) ) { $args[‘meta_key’] = $args[‘orderby’]; } return $args; } add_filter( ‘users_list_table_query_args’, ‘change_user_order’ );
Here’s a way that could be “best” depending on the circumstance: const { meta } = wp.data.select( ‘core’ ).getEntityRecord( ‘postType’, ‘post’, 123 ); This tutorial might be helpful for related stuff.
How to conditionally change template based on ACF field in WordPress 6.5 with FSE theme?
You should be able to order your posts by adding the following to your main args: ‘meta_key’ => ‘date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, Example: $args_post = array ( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘meta_key’ => ‘date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tipo-de-contenido’, … Read more
So, in my case, the answer was simple, though it took a long time to find. Just in case anyone else ever has this issue, here is what solved it for me: I was calling the register_post_meta in a file that was only being included if is_admin() returns true (this is a plugin metabox conversion, … Read more
You can use get_metadata() to retrieve all meta data for a post, by leaving the third and fourth parameters empty. $meta_key string Optional Metadata key. If not specified, retrieve all metadata for the specified object. get_metadata( ‘post’, $post_id );
update and sanitize a value of a select field
display_duration_metabox() function seems to be missing the nonce field save_duration_metabox() is looking for in the first two if statements. Add the missing wp_nonce_field(), with the correct name and action, and the save handler should start working.