Rewrite rule for custom taxonomy

I came up with this with the add_rewrite_rule(): add_rewrite_rule(‘^recipes-with-([^/]*)/?’,’index.php?ingredient=$matches[1]’,’top’); I did some testing for the above, and it works well when you use it for one taxonomy at time. Here is the code from my functions.php: add_action( ‘init’, ‘create_ingredient_tax’ ); function create_ingredient_tax() { register_taxonomy( ‘ingredient’, ‘post’, array( ‘label’ => ‘Ingredient’, ‘hierarchical’ => true ), array( … Read more

wp_options table value

The only really interesting (and very important) part of the 3rd query is this: ‘project_location_children’, ‘a:7:{i:22;a:1:{i:0;i:23;}…etc…}}’ The a:n:{i:n; etc } stuff is a serialized PHP array. WordPress – for some historical reason – keeps track of term children in one option entry per taxonomy term. The painful thing is, that a lot of people don’t … Read more

Remove Custom Taxonomy Base

I think this is possible, but you will need to keep an eye on the order of the rewrite rules. To help you with this I recommend a plugin I wrote to analyze the rewrite rules (soon available in the repository, but you can download a pre-release). First of all, these rules are quite generic, … Read more

Custom metabox for menu administration page?

Just as a follow up for anybody looking to add their own meta boxes to the menu screen, you can do it by using ‘nav-menus’ for the post type: add_action( ‘admin_init’, ‘my_add_meta_box’ ); function my_add_meta_box() { add_meta_box( ‘custom-meta-box’, __(‘My meta box’), ‘my_nav_menu_item_link_meta_box’, ‘nav-menus’, ‘side’, ‘default’ ); } function my_nav_menu_item_link_meta_box() { ?> <div class=”custom-meta-box” id=”custom-meta-box”> Your … Read more

Custom taxonomy position in admin panel

It will definately not show in custom_1 because you probably must have defined it for custom_2.However, you can define a custom submenu with link same as that of the taxonomy in which the parent link is that of custom_2. Following is what i mean. add_submenu_page( ‘edit.php?post_type=custom_1’, ‘Page Title’, ‘Menu Title’, ‘add_users’,’edit-tags.php?taxonomy=custom_taxonomy’, ” );

How to restrict on selecting child taxonomy

Really, you could probably refine this more and come up with better names, I just wanted to make it functional ^_^ ! First thing’s first -> Let’s include JQuery because I don’t want to do this in vanilla JS. function lets_include_jquery() { wp_enqueue_script( ‘jquery’ ); } add_action( ‘admin_enqueue_scripts’, ‘lets_include_jquery’ ); Now let’s throw a script … Read more