Input value from metabox is not found in $_POST after post save

The $_POST[”] has to contain the name attribute of the input field and not the ID. So to modify your code: function silly_display_metabox( $post ) { wp_nonce_field( basename( __FILE__ ), ‘silly_extrnum_nonce’ ); ?> <label for=”sillyNum”>Silly Number</label> <input type=”number” id=”sillyNum” name=”sillyNum” placeholder=”Write a number…”> <?php } And function silly_save_metabox( $post_id ) { $is_autosave = wp_is_post_autosave( $post_id … Read more

Seach custom post type posts only by meta fields?

This might work, not tested though. First add this to join the postmeta table: add_filter( ‘posts_join’, ‘search_filters_join’, 501, 2 ); function search_filters_join( $join, $query ) { global $wpdb; if ( empty( $query->query_vars[ ‘post_type’ ] ) || $query->query_vars[ ‘post_type’ ] !== ‘product’ ) { return $join; // skip processing } if ( ($this->is_ajax_search() || $this->is_search_page()) && … Read more

Automatically add custom fields value to wordpress post

I think update_post_meta( $post_id, ‘HD’, $mydata ); has its arguments in the wrong order and should be update_post_meta( $post_id, ‘quality’, ‘HD’); Alternatively where you need the custom field and it does not exist, why not just use “HD” as a default value? e.g. global $post; $theQuality = empty(get_post_meta( $post->ID, ‘quality’) ? ‘HD’ : get_post_meta( $post->ID, … Read more