Saving multiple Metabox contents

Aha! Stupid error. I didn’t give it a proper METAKEY! This seems to have fixed things: /* Save the meta box’s post metadata. */ function save_metabox_exhibition( $post_id, $post ) { $fields = 0; if($_POST) { $metaboxes[0][‘nonce’] = $_POST[‘exhibition_finish_date_nonce’]; $metaboxes[0][‘data’] = $_POST[‘gc_finish_date’]; $metaboxes[0][‘meta’] = ‘gc_finish_date’; $metaboxes[1][‘nonce’] = $_POST[‘exhibition_start_date_nonce’]; $metaboxes[1][‘data’] = $_POST[‘gc_start_date’]; $metaboxes[1][‘meta’] = ‘gc_start_date’; $metaboxes[2][‘nonce’] = … Read more

Rewrite custom post & taxonomy to share same URL path

(Revised on March 7th 2020 UTC) So sharing the same permalink path (or rewrite slug/base as in example.com/<rewrite slug>/<term slug> and example.com/<rewrite slug>/<post slug>) is possible, and here’s the (updated) code which enables you to share the exact same rewrite slug between a taxonomy and a post type: function wpse_358157_parse_request( $wp ) { $path=”about-us/video-center”; // … Read more

Count custom post types with a specific meta value

1st. you need to add post_type to your query, then you need to filter meta_value with LIKE. Finaly, you need to add posts_per_page as -1 to get ALL posts. $args = array( ‘post_type’=> ‘books’, ‘meta_query’ => array( array( ‘key’ => ‘book_type’, ‘value’ => ‘Fiction’, ‘compare’ => ‘LIKE’, ) ), ); $query = new WP_Query($args); $fiction … Read more

Conditional two level dropdown filter for custom post type

Like I said in the comment, this can be solved by using two dropdowns. Additionally I already hinted you to an answer of mine doing this for a simple, one level, non conditional category selection. Category dropdowns can easily constructed with wordpress by making use of wp_dropdown_categories. To make it work as actual selection handed … Read more

How can I remove categories in menu in custom post type?

This was hacked together very quickly. I don’t for sure if there will be problems with translation, but I be there would be. function remove_menu_from_cpt() { global $submenu; $post_type=”book”; $tax_slug = ‘post_tag’; if (isset($submenu[‘edit.php?post_type=”.$post_type])) { foreach ($submenu[“edit.php?post_type=”.$post_type] as $k => $sub) { if (false !== strpos($sub[2],$tax_slug)) { unset($submenu[“edit.php?post_type=”.$post_type][$k]); } } } } add_action(“admin_menu’,’remove_menu_from_cpt’); It used … Read more