Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$15
Custom taxonomy term picker for a widget
What I need is a function/method that gets passed a taxonomy and it returns a picker (radios, not checkboxes)
e.g.
echo generate_picker("post_tag");
to return something like the attached screenshot -- and whatever term is selected it updates a hidden input field with its id.
Let me know if this doesn't make sense.
Thanks,
MR
mackrider | 08/07/12 at 3:40pm
Edit
(2) Possible Answers Submitted...
Note: mackrider felt their question was unanswered, so we granted them a refund.
Note: mackrider requested a refund. They offered this explanation:
"Never received a useable response."If no one challenges a refund request, then they are automatically granted and proccessed after 48 hours. Admins of this site only review refund requests if someone challenges the request. If you are curious about how we handled previous refund requests, you may read over all refund requests and their challenges.
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
08/07/12
4:37pmJatin Soni says:Here is the function
add_action( 'admin_footer', 'catlist2radio' );
function catlist2radio(){
echo '<script type="text/javascript">';
echo 'jQuery("#categorychecklist input, #categorychecklist-pop input, .cat-checklist input")';
echo '.each(function(){this.type="radio"});</script>';
}
If you want allow admin can select multiple category than use below code
function the_user_level () {
if (is_user_logged_in()) {
global $current_user, $wpdb;
$userLevel = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE user_id=$current_user->id AND meta_key='wp_user_level'");
return $userLevel;
} else {
return 0;
}
}
$accessLevel = the_user_level();
if ($accessLevel < 8) {
add_action( 'admin_footer', 'catlist2radio' );
function catlist2radio(){
echo '<script type="text/javascript">';
echo 'jQuery("#categorychecklist input, #categorychecklist-pop input, .cat-checklist input")';
echo '.each(function(){this.type="radio"});</script>';
}
}else {
echo '';
}- 08/07/12 4:42pm
mackrider says:Not sure I follow
As I stated in my question --> I want something as easy as
echo generate_picker("post_tag"); - 08/07/12 4:49pm
Jatin Soni says:Where you want to put this? This code you need to place in function.php and nothing require you to do. It will automatically convert all taxonomy checkbox with radio button.
- 08/07/12 4:51pm
mackrider says:I am adding a widget that allows a user to select a term from selected taxonomies (there will be additional functionality, but this is the one piece I was unsure how to build).
What I need is a taxonomy picker that looks like that screenshot for the widgets.
This is going to go in the widget area in wp_admin.
- 08/07/12 4:42pm
-

Last edited:
08/07/12
10:48pmArnav Joy says:define this function in functions.php
<?php
function generate_picker($tax='category'){
$terms = get_terms($tax);
$count = count($terms);
if ( $count > 0 ){
foreach ( $terms as $term ) {
$str .= '<input type="radio" name="picker" value="'.$term->term_id.'" >'.$term->name.'<br>';
}
}
return $str;
}
?>
and use it as you wanted :-
<?php echo generate_picker("post_tag");
?>
now you can use its value after form submission <?php echo $_REQUEST['picker'];?> this will give you selected term's id- 08/07/12 11:17pm
mackrider says:Looks good. I just need it in the three tabs: most used / all (paginated) / search - use the image as a reference. :)
- 08/07/12 11:17pm
This question has expired.
Current status of this question: Refunded
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
