Is it possible to dynamically register menus?

Register a menu is really register a menu location, but I think you don’t need to register locations so you can avoid the register step. I think what you need is wp_nav_menu( ) function. For example, in the page template: //Get the menu slug stored in page custom meta field //Replace menu_meta_field_name with the correct … Read more

save metabox with new values _wp_page_template

I swear to god…..!!! Every time I ask a question here I seem to find the answer…. I missed the verification: echo ‘<input type=”hidden” name=”meta_box_template_picker_nonce” value=”‘.wp_create_nonce(basename(__FILE__)).'” />’; Below is the complete code. If you think you can use this please do. If you wish to use it but don’t know how: 1. Create a seperate … Read more

How to restrict the amount of categories/post tags/terms for a post type post

Thanks the the replies. I solved my problem with jQuery. Here is the code: jQuery(document).ready(function ($) { $(“#category-tabs li.hide-if-no-js”).hide(); //Hides Most Used tab $(“#category-all input:checkbox”).change(function () { var max = 2; // Max allowed cats var count = $(“#category-all input:checked”).length; //counts selected cats if (count > max) { $(this).prop(“checked”, “”); alert(‘You are only allowed to … Read more

How to add a text widget on the posts admin page?

You can add a “Meta Box” to the admin screen of edit post/page. WordPress have the function add_meta_box function for this job. The content inside this meta box is your choice. You can define, on which area of the edit screen will add the box, like sidebar or central area. Also you have the benefits, … Read more

Let author add field to metabox by pressing a button

I packed everything together. Consider using wp_enqueue_script() to use the script. With this code, you will save all URLs as an array. See how I use get_post_meta() to retrieve the saved URLs. function save_custom_metabox($post_id){ if(!isset($_POST[‘source_post_metabox_nonce’])) : return; endif; if(!wp_verify_nonce( $_POST[‘source_post_metabox_nonce’], ‘source_post_metabox’)) : return; endif; if(defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) : return; endif; if(!current_user_can(‘edit_post’, $post_id)) return; if ( … Read more