• WordPress Custom Taxonomy Input Panels
    by ShibaShake
    [   See Full Article   ]
    90 Comments
    1. James Chester

      Great tutorial, I am working on a custom post type and I’ve created a custom metabox drop down for AM or PM but it won’t save my value. Can someone help me? I’m in a jam with my deadline looming. I can send my code.

      Best,
      James

      11:33 am on April 5th, 2012 Reply
      • If something is not saving, I usually just try to echo something out in the save_taxonomy_data function and then exit. For example -

        print_r($_POST); exit;

        This lets me know if I am hitting the save function, and what input values it is getting.

        11:57 am on April 10th, 2012 Reply
    2. [...] Would you like to add new custom fields to your WordPress posts, pages, and categories? Now you can easily do this with the WordPress custom taxonomy system . For example, if you have a blog on movie reviews, you may want to add the fields Actors and Genre to each of your posts. WordPress Custom Taxonomy Input Panels [...]

      1:49 am on April 3rd, 2012 Reply
    3. Robbert

      Hi,
      I got it all working in my backend (created custom taxonomy drop down, saves, updates etc), but is there any possibility to use the custom taxonomies on my front-end form?

      I use a custom made front-end form. How can i display the custom made taxonomy dropdown there and be save the data once the user sends the form? Is there any code or source i can use for this?

      thnx!

      9:19 am on March 20th, 2012 Reply
    4. John

      Thanks for the tutorial. One question, can I allow multiple selection using:
      <select multiple ='multiple'…
      I get the expected result visually, but as expected only the last value is saved. Is there a way to extend the save_taxonomy_data function to hold multiple ie array of values.
      Thanks again,
      John

      7:34 pm on March 9th, 2012 Reply
      • Try -

        <select name='post_theme[]' id='post_theme' multiple>
        1:33 am on March 10th, 2012 Reply
        • spo

          Any ideas for using checkboxes?

          Have come up with:


          echo "name . "' value='" . $theme->slug . "' checked='yes'>" . $theme->name . "\n";
          else
          echo "name . "' value='" . $theme->slug . "' >" . $theme->name . "\n";

          However, will only save the first option if more then one is checked, or the checked option if only one.

          10:39 pm on April 15th, 2012 Reply
          • For multiple selections the name should have square brackets.

            <input type="checkbox" name="myname[]" value="1"/>One
            7:22 am on May 1st, 2012 Reply
            • spo

              Thanks for the reply!

              Originally I posted with [code] and this is what I had..

              if (!is_wp_error($names) && !empty($names) && !strcmp($theme->slug, $names[0]->slug))
              			echo "slug . "' checked='yes'>" . $theme->name . "\n";
              		else
              			echo "slug . "' >" . $theme->name . "\n";
              

              So, as stated, still only saves first option or onle of the selected..

              Do I need to define an array before wp_set_object_terms() and if so, where?

              6:00 pm on May 1st, 2012
            • Instead of doing !strcmp($theme->slug, $names[0]->slug), you would need to check for the entire $names array with something like an in_array.

              8:32 pm on May 1st, 2012
    5. kathy

      so i’ve successfully implemented both this and you ‘expand the wordpress quick edit’ tutorial. compliments on such intricate and valuable tutorials. i have learned a ton from your site that i can’t find anywhere else. i’m finding that if i do both, however, then i end up w/ two actions attached the the save_post hook and this is causing problems with undefined indexes: ie. nonces from one that aren’t in the $_POST of the other. can you think of a check to only run the added function if it is run on the quick edit screen versus if it is run on the normal edit post page?

      6:45 am on January 7th, 2012 Reply
      • kathy

        turns out that you can test for whether the save is coming from the quick edit screen by checking if $_POST['action'] == ‘inline-save’. (i believe it equals ‘edit’ from the edit screen.

        however, in the end, i decided it was redundant to have 2 functions attached to ‘save_post’ to do the same thing: since the taxonomy metabox and the quick edit box are handling the same data, so i combined them into 1 function. works great. i was concerned about needing to use different nonces, but WP uses the same nonce name (‘_wpnonce’) in both places, so i figured i could too. thanks again!

        11:38 am on January 7th, 2012 Reply
    6. [...] WordPress Custom Taxonomy Input Panels remove_meta_box ( 'tagsdiv-theme' , 'post' , 'core' ) ; Note – For non-hierarchical taxonomies (like tags) you want to use tagsdiv-{$taxonomy_name}, e.g. tagsdiv-theme . For hierarchical taxonomies (like categories) you want to use {$taxonomy_name}div, e.g. themediv . [...]

      5:52 am on December 15th, 2011 Reply
    7. Great tutorial. If anyone is already using WPAlchemy Metaboxes, I did a small tutorial on how to use your method together with it. My tutorial can be found Custom taxonomy metaboxes with WPAlchemy MetaBox. Thanks!

      3:57 pm on November 5th, 2011 Reply
    8. [...] I came across this awesome resource on “WordPress Custom Taxonomy Input Panels” by shibashake that sparked the idea. I will be doing something almost similar, except I’ll be [...]

      2:48 pm on November 5th, 2011 Reply
    9. Ted

      Hi Shibashake, thanks for the great tutorial. I’ve gotten everything to work, but am stuck on removing a meta box (input field) from the custom taxonomy “Add New Category” page and “Edit Category” page.

      By default, the input fields for creating or editing a category are “Name”, “Slug”, “Parent”, and “Description”. I’m trying to remove the “Description” field but can’t figure out how.

      I was even just thinking about setting that field to display: none but it doesn’t have a unique class or id. Any ideas? Thanks!

      9:23 am on October 25th, 2011 Reply
      • Ted

        so after a lot of trial and error, i managed to remove the description field via a jquery hack.


        // this removes the admin description input field when var userSettings pagenow is edit-erw_menu_cats
        function erw_hide_descrip()
        {
        echo "

        if ( pagenow == 'edit-erw_menu_cats') { // begin conditional
        $(function(){
        $('div.wrap form.validate table.form-table tr.form-field:last').hide(); // removed from edit category page
        $('div.col-wrap div.form-wrap div.form-field:last').hide(); // removed from add new category page
        });
        }; // end conditional

        ";
        }
        add_action( 'admin_head', 'erw_hide_descrip' );

        The only problem is, that now I’m wanting to add an input field on the custom taxonomy “Add New Category” page and “Edit Category” page but have no idea how to do this. any clues?

        6:40 pm on October 25th, 2011 Reply
    10. eko lesmana

      can i use this at WP 3.2.1?

      6:15 pm on September 27th, 2011 Reply
      • It should work since I use it in several of my plugins. Let me know if you run into any problems.

        3:41 pm on September 28th, 2011 Reply
        • Anonymous

          thanks for your quick reply , shibashake.

          let just say, in my database, term_id for Halloween is 13. i made a post and i choosed theme ‘Halloween’. after that, i clicked Publish button. then i checked wp_posts, the id of my post is 15. then i checked wp_term_relationships, only object_id with id 15 and term_taxonomy_id is 1. not object_id with id 15 and term_taxonomy_id is 13.

          6:18 pm on September 28th, 2011 Reply
          • Anonymous

            finally i can do it, shibashake.

            maybe i lost one step. thanks for your great tutorials.

            8:26 pm on September 28th, 2011 Reply
            • eko lesmana

              i have another question, shibasake.
              how to make dropdown to be checkbox?
              and how to save the data?
              help me please…

              9:45 pm on September 28th, 2011

    Leave a Reply

    Your email address will not be published.

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

    search button search button
    rss