Wednesday, September 14, 2011

How Do I Change a Link List To Drop Down List in PHP for Wordpress?

I've got a piece of code in a widget which I would like to change from a list of links of the category into a drop down list instead. The code is below:



function widget_category_list($args)

{

global $wpdb, $wpdir;



$data = get_option('wpdir_Widget');

$query = %26quot;select * from %26quot; . $wpdb-%26gt;prefix . %26quot;wpdir_category cat, %26quot; . $wpdb-%26gt;prefix . %26quot;wpdir_category_path path where cat.category_id = path.category_id and cat.parent_id = 0 and cat.visible = 1 order by cat.name asc limit %26quot; . $data['cat_limit'];

$content = $wpdb-%26gt;get_results($query);



echo $args['before_widget'];

echo $args['before_title'];

echo $data['cat_title'];

echo $args['after_title'];

echo %26quot;%26lt;ul%26gt;%26quot;;



$counter = 0;



foreach($content as $data)

{



echo %26quot;%26lt;li%26quot;;

if ($counter % 2 == 0){ echo %26quot; class='alternate_cell'%26quot;; }

echo %26quot;%26gt;%26quot;;

echo %26quot;%26lt;a href=\%26quot;%26quot;.$wpdir-%26gt;config['url_permalink']?br>
echo $data-%26gt;name. %26quot; (%26quot; . $data-%26gt;number_link . %26quot;)%26quot;;

echo %26quot;%26lt;/a%26gt;%26quot;;

echo %26quot;%26lt;/li%26gt;%26quot;;

$counter ++;

}



echo %26quot;%26lt;/ul%26gt;%26quot;;

echo $args['after_widget'];

}



function register()

{

register_sidebar_widget('WPDIR Category List', array('wpdir_Widget', 'widget_category_list'));

register_widget_control('WPDIR Category List', array('wpdir_Widget', 'control_widget_category_list'));

}



}



Would really appreciate some help...



Cheers,



-WilliamHow Do I Change a Link List To Drop Down List in PHP for Wordpress?two