New answers tagged

0

Using the wp_dropdown_categories() function there's a parameter you can use called selected which you would assign the selected category ID. You should also standardize the name of your select so it's easier to save: $selected_id = get_post_meta( $post->ID, 'selected_tax', true ); wp_dropdown_categories( array( 'show_option_all' => 'Choose a ...


2

I will suggest to check the $post object in PHP before adding meta box. And add the meta box if status is draft or auto-draft. Consider this code function update_meta_boxes($current_post_type, $post) { $post_types = apply_filters('lsw_default_post_types', LSW_Organize_Drafts::$post_types); remove_meta_box( 'tagsdiv-lswdrafttype', $post_types, ...


0

If you are manually registering your custom taxonomy via register_taxonomy then you can pass in arguments to control where the metabox appears. In the example below setting show_ui to false would completely remove the metabox from the edit screen, the quick edit screen, and the admin menu. But if you set show_ui to true you can achieve more nuanced control ...


1

You need to loop through your posts, and retrieve the metadata for each post. Add them to your array, and encode them to JSON. $posts = $query->get_posts(); foreach( $posts as &$thispost ) { // reference the current item $thispost->meta = get_post_meta( $thispost->ID ); } Now you got a WP_Post-Object, with all the post meta available at ...


2

Wordpress comes preloaded with the scripts to do datepickers. If you dont want to do it with a plugin, create a regular text metabox, then you need to enqueue a custom script in the wordpress admin with jquery-ui and jquery-ui-datepicker dependencies: function enqueue_date_picker(){ wp_enqueue_script( 'field-date', ...



Top 50 recent answers are included