How to insert checkbox of categories in Wiki Front end editor?


I want to change the selector of categories at front end editor(in wiki plugin).

Now, to select categories, select box is appeared.
<select name='incsub_wiki_category' id='incsub_wiki_category' class='' >

But then,User can only select one category.
He can't select plural categories at the same time.
So, I want to change that to checkbox.
like this.

<input type="checkbox" name='incsub_wiki_category' id='incsub_wiki_category' class=''>....


May be, wiki plugin's front end editor uses TinyMCE,But I don't find the part of that.

What files do I have to change?
(Hopefully, I want to use plugin to do that.)

  • Koji
    • Design Lord, Child of Thor

    Thank you @Vaughan!

    I lose no time in trying it, but wp_category_checklist was undefined function...
    (wp_term_checklist either)

    In my search, a few people has same problem.
    Do you know about this?



  • Vaughan
    • Support/SLS MockingJay


    Very strange.

    I just ran a search on 3.8.1, it's definitely present. but looks like it's deprecated, though it should still work. The codex doesn't say anything about it being deprecated though.

    This might help.

    I think it's only in the admin side by looks of it,

    You might be able to do it by writing your own function instead.

    This should help.

    Hope this helps.

  • Koji
    • Design Lord, Child of Thor


    Thank you @Vaughan

    I tried "str_replace" because, making a new function is a little bit hard.
    I set like this.
    $content = str_replace( "<select name='incsub_wiki_category' id='incsub_wiki_category' class='' >", "", $content );
    $content = str_replace( "<option", "<input type='checkbox' name='incsub_wiki_category'", $content );
    $content = str_replace( 'selected="selected"', " checked", $content );
    $content = str_replace( "</option>", "
    ", $content );
    $content = str_replace( "</select>", "", $content );


    and actually appear checkbox.
    But, If I post the data, only a last category item is effective,not plural categories.
    Maybe, wiki.php accepts only one item of categories.

    Default function wp_dropdown_categories is now only one item selected too.

    Can I change that?(What line do I have to change?)

    And hopefully, I want you will implement wiki-plugin for "plural categories" in next version.
    Because,If admin makes wiki-page in plural categories,Now version can't correspond.



    If you say that's

  • Koji
    • Design Lord, Child of Thor

    Hello @Vaughan

    I'm waiting 5 days.
    Could you please answer?
    (Maybe, My English was poor.So I'm going to ask again.)

    In my test, I think that "wiki.php" accepts only one item of categories.
    If I change "selector" to "checkbox", it's not effective.(because only one item is accepted in any case)

    Is this right?

    If so,Do you have any idea to solve the problem, or Could you solve this problem in next version?

    Because ,Usually, a wiki-page often belongs to plural categories.
    Many person thinks that.



  • Jose
    • Bruno Diaz

    Hi @Koji,

    I hope you're well today.

    I was looking at your workaround and it looks good. You just forgot the [] at the end of the name attribute.

    So, your final code should be something like this:

    $dropdownList = wp_dropdown_categories( array(
    		'orderby' => 'name',
    		'order' => 'ASC',
    		'taxonomy' => 'incsub_wiki_category',
    		'selected' => $wiki_cat,
    		'hide_empty' => false,
    		'hierarchical' => true,
    		'name' => 'incsub_wiki_category',
    		'class' => '',
    		'echo' => false,
    		'show_option_none' => __( 'Select category...', 'wiki')
    					) );
    $checkboxList = str_replace( "<select name='incsub_wiki_category' id='incsub_wiki_category' class='' >", "", $dropdownList );
    $checkboxList = str_replace( "<option", "<input type='checkbox' name='incsub_wiki_category[]'", $checkboxList );
    $checkboxList = str_replace( 'selected="selected"', " checked", $checkboxList );
    $checkboxList = str_replace( "</option>", "", $checkboxList );
    $checkboxList = str_replace( "</select>", "", $checkboxList );
    $content .= $checkboxList;

    Also, you can render a multiple dropdown list, which also allows to select more that one item at the same time:

    $dropdownList = wp_dropdown_categories( array(
    		'orderby' => 'name',
    		'order' => 'ASC',
    		'taxonomy' => 'incsub_wiki_category',
    		'selected' => $wiki_cat,
    		'hide_empty' => false,
    		'hierarchical' => true,
    		'name' => 'incsub_wiki_category',
    		'class' => '',
    		'echo' => false,
    		'show_option_none' => __( 'Select category...', 'wiki')
    					) );
    $dropdownList = str_replace( "name='incsub_wiki_category' id=", "name='incsub_wiki_category[]' multiple='multiple' id=", $dropdownList );
    $content .= $dropdownList;

    Please let me know if any of these options works for you, and sorry again for the delay on the thread.


  • Koji
    • Design Lord, Child of Thor

    Hi @Jose.
    I'm sorry. I'm delay to try it.

    Result is little bit wrong.

    Actually, To use str_replace(the former), Checkbox is appeared.
    But only one item can be selected. I can't select multiple categories at the same time.
    So this work around is not enough.

    And the later, It's not effective.

    So, I' ll give up to use checkbox,
    Hopefully please implement check box instead of list box in next version.

    Thanks Koji.

  • Hoang Ngo
    • Code Slayer

    Hi @Koji,

    I hope you are well today.

    Instead of making it multiple checkbox, it will be easier to make it as multiple dropdown. So we don't have to modify the core code too.

    Please add this code to your functions.php or use mu-plugins:

    function checked_wiki_categories(){
    	global $post, $edit_post;
    	$wiki = isset($post) ? $post : $edit_post;
    	$wiki_cats = wp_get_object_terms( $wiki->ID, 'incsub_wiki_category', array( 'fields' => 'ids' ) );
    	<script type="text/javascript">
    			jQuery.each(<?php echo json_encode($wiki_cats) ?>,function(index,value){
    				jQuery('#incsub_wiki_category option[value="'+value+'"]').prop('selected',true);
    function wiki_add_multiple_categories($post_id){
    	$wiki_category = $_POST['incsub_wiki_category'];
    	wp_set_post_terms( $post_id, $wiki_category, 'incsub_wiki_category' );

    Best Regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.