Get category slug and display it on a query_post

I just read “How to create option page for wordpress theme” in wp.tutsplus.com – I have a problem with getting categories .

there is two parts to my question

– Part A – Get category slug and display it

In this tutorial there is a select option as follow :

$options[] = array(
    "section" => "select_section",
    "id"      => WPTUTS_SHORTNAME . "_select_input",
    "title"   => __( 'Select (type one)', 'wptuts_textdomain' ),
    "desc"    => __( 'A regular select form field', 'wptuts_textdomain' ),
    "type"    => "select",
    "std"    => "3",
    "choices" => array( "1", "2", "3")

Now, instead of the 1-2-3 choices , I want to return category slugs to display it to user – can someone please modify this code so it return the slugs for categories created on the site?

– Part B – Display category slug in query_posts format

The typical returning value for above code is this :

<?php echo $wptuts_option['wptuts_select_input']; ?>

I use this code for my query post :

<?php query_posts('showposts=1&category_name=news'); ?>

where the “news” is the category “slug” – not name of the category
now , can someone please modify the code so it gets the category slug based on the option chose in the theme option page ?

I am stuck in fixing this problem and I looked every where, but cant find a solution
thanks

3 Answers
3

I am not positive how to do what you want. But I have been using this framework which is very similar to what you have above but is much easier to use

http://aquagraphite.com/2011/11/smof-documentation/

setting up options is really easy and it is supported through github. There is a place to ask these exact kind of questions. That and the framework has a lot of examples in it that you can copy and paste to get your admin area up and running. I just commented out all the example options so that I could reference them when I wanted to create one of them.

As for your answer. I don’t know how to do you but you could try some things like this

"choices" => get_categories(  ); 

Leave a Comment