Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Articles / Source Code > Site Management > CMS

Discuss / Comment  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More
 
Bookmarks Article Tools Search this Article Display Modes

Getting Wordpress Blog Authors in Combobox


On 12th March, 2010
Wink Getting Wordpress Blog Authors in Combobox

Show Printable Version Email this Page Subscription Add to Favorites Copy Getting Wordpress Blog Authors in Combobox link

Author

shabbir ( Go4Expert Founder )

Shabbir is a developer in the field of Applications, web as well as database designing and is devoted to the optimization and usability of the code. He maintains Programming forum and is a C++ addict.


All articles By shabbir

Recent Articles

Similar Articles

Introduction



I expected wordpress to have some built in support for listing all authors of the blog in a select box but that is not the case yet in Wordpress 2.9.2.

I was certain that I can get this done using wp_list_authors but actually it was a not that straight forward and so let me share this with you. I think this will help those looking for such functionality.

The Code



What I did is replaced the content of list items ( <li> ) into select box options ( <option> ) and added a JavaScript function to redirect user to the url when there is a change in the selection in the selection box.

So here is the code.
Code:
<select id="AuthorList" name="AuthorList" onchange="goAuthorList();">
	<?php 
	$authargs = array(
		'optioncount'   => false, 
		'exclude_admin' => false, 
		'show_fullname' => false,
		'hide_empty'    => true,
		'echo'          => false, // We will not output using the function.
		'feed'          => false, 
		'feed_image'    => false,
		'style'         => 'list',
		'html'          => true 
	); 
	$var_list = wp_list_authors( $authargs ); // Take the output into a variable.
	// Replace the tags of list to option box
	$var_list = str_replace("</a></li>","</option>",$var_list); 
	$var_list = str_replace("<li><a href=","<option value=",$var_list);
	// Now output the list
	echo $var_list;	
	?> 
</select>
<script language="JavaScript">
<!--
    function goAuthorList() {
	// JavaScript function to change the user to the url of the author
		theSelAuthor = document.getElementById("AuthorList").value;
			if ("" != theSelAuthor) location.href = theSelAuthor;
    }
//-->
</script>
Enjoy !!!
Old 03-12-2010, 10:01 PM   #2
Skilled contributor
 
hanleyhansen's Avatar
 
Join Date: Jan 2008
Location: Passaic
Posts: 254
Thanks: 13
Thanked 2 Times in 2 Posts
Rep Power: 3
hanleyhansen is on a distinguished road
Send a message via AIM to hanleyhansen Send a message via MSN to hanleyhansen

Re: Getting Wordpress Blog Authors in Combobox


Cool!
hanleyhansen is offline   Reply With Quote
Old 03-14-2010, 07:54 AM   #3
Skilled contributor
 
pankaj.sea's Avatar
 
Join Date: Apr 2009
Location: Some Where I Belong . . .
Posts: 274
Thanks: 1
Thanked 6 Times in 4 Posts
Rep Power: 2
pankaj.sea is on a distinguished road
Send a message via Yahoo to pankaj.sea

Re: Getting Wordpress Blog Authors in Combobox


Nice Info!
pankaj.sea is offline   Reply With Quote
Old 04-02-2010, 09:11 AM   #4
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,750
Thanks: 131
Thanked 294 Times in 228 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Getting Wordpress Blog Authors in Combobox


If you like this this article nominate it for Article of the month - Mar 2010
shabbir is offline   Reply With Quote
Old 04-16-2010, 07:44 PM   #5
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,750
Thanks: 131
Thanked 294 Times in 228 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Getting Wordpress Blog Authors in Combobox


Vote for this article for Article of the month - Mar 2010
shabbir is offline   Reply With Quote
Old 07-30-2010, 08:19 PM   #6
Contributor
 
Join Date: Jul 2010
Posts: 89
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 1
johnny.dacu is on a distinguished road

Re: Getting Wordpress Blog Authors in Combobox


Why to list authors in a select? What's wrong with a list style?
__________________
Photonics Market
johnny.dacu is offline   Reply With Quote
Discuss / Comment  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More


Currently Active Users Reading This Article: 1 (0 members and 1 guests)
 
Article Tools Search this Article
Search this Article:

Advanced Search
Display Modes
Bookmarks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

 

All times are GMT +5.5. The time now is 03:14 PM.