Custom meta fields for specific custom type only

EDIT: I also recommand you to use nonces to check your field before saving. EDIT2: Nonces Just before field, define a nonce : wp_nonce_field( ‘curiculum_meta_box_nonce’, ‘meta_box_nonce’ ); Your saving function is not correct, use this instead : function save_curiculum_date($postid) { //stop if autosave if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // if our nonce … Read more

Loading scripts to the Post Edit page only

We can improve a little bit with : function specific_enqueue($hook_suffix) { if( ‘post.php’ == $hook_suffix || ‘post-new.php’ == $hook_suffix ) { wp_enqueue_script( ‘custom_js’, get_template_directory_uri() . ‘/inc/meta/custom.js’, array( ‘jquery’ )); wp_enqueue_style( ‘custom_css’, get_template_directory_uri() . ‘/inc/meta/custom.css’) } } add_action( ‘admin_enqueue_scripts’, ‘specific_enqueue’ );

Custom fields on a virtual page

If you use get_post_meta in the template, that calls get_metadata with meta type post, which contains the filter get_{$meta_type}_metadata, which in this case will be get_post_metadata. There you can check the key and return whatever data you want. function wpd_fake_meta( $meta_data, $object_id, $meta_key, $single ){ if( ‘somekey’ == $meta_key ){ return ‘somefakevalue’; } return null; … Read more

Query Custom Post Types by date (custom field) range

I think it’s mainly because of the type parameter. You are probably looking for meta_query. Take a look at the following example from the codex: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(3, 4), ‘compare’ => ‘IN’, ) … Read more