Get category slug and display it on a query_post


I just read “How to create option page for wordpress theme” in – 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

, , Dave 11 years 2012-04-01T11:09:48-05:00 0 Answers 96 views 0

Leave an answer