I'm working on a wordpress website now but I have a problem with a dropdown on a taxonomy. This code is in a public form so that the visitor send a recipe, taxonomy is the ingredients which already registered on the website.
With the current dropdown, everything works fine, displaying taxonomies, and viewing once in the admin.
With this code, i have a basic dropdown, but i want one with a checklist.
<?php wp_dropdown_categories( 'tab_index=25&taxonomy=ingredient-listing&name=ingredient-listing&show_option_none='.__('Choisir','FoodRecipe').'&hide_empty=0' ); ?>
I try with this code :
<?php wp_category_checklist( 'tab_index=25&taxonomy=ingredient-listing&name=ingredient-listing&show_option_none='.__('Choisir','FoodRecipe').'&hide_empty=0' ); ?>
and this code in functions.php
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
wp_terms_checklist( $post_id, array(
'taxonomy' => 'category',
'descendants_and_self' => $descendants_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => $popular_cats,
'walker' => $walker,
'checked_ontop' => $checked_ontop
) );
}
But doesn't work, i have a Fatal error.
The function category checklist already exists but wp-admin side, so I think not accessible side wp-content ...
Do you have any idea?
Thanks you very much
Nathy
I'm working on a wordpress website now but I have a problem with a dropdown on a taxonomy. This code is in a public form so that the visitor send a recipe, taxonomy is the ingredients which already registered on the website.
With the current dropdown, everything works fine, displaying taxonomies, and viewing once in the admin.
With this code, i have a basic dropdown, but i want one with a checklist.
<?php wp_dropdown_categories( 'tab_index=25&taxonomy=ingredient-listing&name=ingredient-listing&show_option_none='.__('Choisir','FoodRecipe').'&hide_empty=0' ); ?>
I try with this code :
<?php wp_category_checklist( 'tab_index=25&taxonomy=ingredient-listing&name=ingredient-listing&show_option_none='.__('Choisir','FoodRecipe').'&hide_empty=0' ); ?>
and this code in functions.php
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
wp_terms_checklist( $post_id, array(
'taxonomy' => 'category',
'descendants_and_self' => $descendants_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => $popular_cats,
'walker' => $walker,
'checked_ontop' => $checked_ontop
) );
}
But doesn't work, i have a Fatal error.
The function category checklist already exists but wp-admin side, so I think not accessible side wp-content ...
Do you have any idea?
Thanks you very much
Nathy
Share Improve this question edited Oct 22, 2014 at 22:33 Ashok Kumar Nath 6434 silver badges10 bronze badges asked Oct 22, 2014 at 18:29 NathyNathy 12 bronze badges 2- Post the complete error message please – s_ha_dum Commented Oct 22, 2014 at 18:37
- Hello ! Fatal error: Call to undefined function wp_terms_checklist() in /web/tambouill/www/wp-content/themes/food-recipes/functions.php on line 630 – Nathy Commented Oct 22, 2014 at 18:40
1 Answer
Reset to default 1wp_terms_checklist()
is an admin side function as you suspect.
I don't recommend trying to load admin side code on the front end (especially if you are not very very familiar with its inner workings) so essentially you are left with rolling your own code to create the checklist.
You should be able to use the wp_terms_checklist()
code as a model, but it may be that that code is far more complicated than you need it to be. It is hard to tell without more detail about your specific problem.