Funny, I’ve just investigated the matter due to a similar question on polish wordpress support forum. The only thing I have found out that no one really knows what is going on… Weird indeed.
Kailoon, I had the same problem. I expertimented with the code – but it didn’t work. Btw, the dropdown for pages worked ok. I couldn’t find a solution and made textboxes for users to enter ids of categories.
It seems as though
get_categories() can not run correctly inside functions.php
For example, if I place:
<pre><?php print_r(get_categories()); ?></pre>
inside footer.php (or any other template file), the categories are returned correctly.
However, I run the code inside functions.php, and an ‘invalid_taxonomy’ error is output.
Are you sure your $site_cats array is getting populated?
Could you just test this out for me.. Add the following code to the very top of your functions.php file (inside <?php):
echo '<pre>'; print_r(get_categories('hide_empty=0')); echo '</pre>';
Then open your WordPress in your browser (either the front site, or dashboard). From the top of the page should be the output of get_categories().
When I do this in WordPress 2.7, categories are returned correctly, like so:
Array (  => stdClass Object ( [term_id] => 3 [name] => Tutorials [slug] => tutorials [term_group] => 0 [term_taxonomy_id] => 3 [taxonomy] => category [description] => [parent] => 0 [count] => 5 [cat_ID] => 3 [category_count] => 5 [category_description] => [cat_name] => Tutorials [category_nicename] => tutorials [category_parent] => 0 ) .... .... )
But when I do this in 2.8, this is output:
Array ( [errors] => Array ( [invalid_taxonomy] => Array (  => Invalid Taxonomy ) ) [error_data] => Array ( ) )