Getting posts by custom field value

first, you have to loop through all posts that have this meta key (your custom field) and then update post meta with replacing the word (from) to leave the number alone in the meta value. //paste the following code in your plugin or theme functions.php add_action( ‘init’, function () { if ( ! get_option( ‘prefix_correct_data’ … Read more

register_rest_field update_callback don’t work for $_FILES

I found a solution but i’m sure there is a better way. I add an action on rest_insert_<post_type> hook add_action( ‘rest_insert_project’, ‘prefix_update_files_field’, 10 , 3 ); function prefix_update_files_field($post, $request, $true){ global $wp_rest_additional_fields; $my_post_type=”project”; $additional_fields = $wp_rest_additional_fields[$my_post_type]; foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options[‘update_callback’] ) { continue; } // Don’t … Read more

How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?

get_post() and get_post_meta() should work to collect the data and array_multisort() should be able to sort it into ascending order. // Query the database to get the posts from your post types $project_args = array( ‘post_type’ => ‘projects’, “numberposts” => -1 ); $task_args = array( ‘post_type’ => ‘tasks’, “numberposts” => -1 ); $material_args = array( … Read more