theme development - How to show post from category select

This code is in my functions.php:array( "name" => "Headline","type" => "sectio

This code is in my functions.php:

array( "name" => "Headline",
"type" => "section"),
array( "type" => "open"),

array( "name" => "Headline  Categories",
"desc" => "Choose a category from which featured posts are drawn",
"id" => $shortname."_headline",
"type" => "select",
"options" => $wp_getcat,
"std" => "Select a category"),

array( "type" => "close"),

Now, how to show posts from category select on page.php or page template?

This code is in my functions.php:

array( "name" => "Headline",
"type" => "section"),
array( "type" => "open"),

array( "name" => "Headline  Categories",
"desc" => "Choose a category from which featured posts are drawn",
"id" => $shortname."_headline",
"type" => "select",
"options" => $wp_getcat,
"std" => "Select a category"),

array( "type" => "close"),

Now, how to show posts from category select on page.php or page template?

Share Improve this question edited Jan 28, 2014 at 3:45 Mayeenul Islam 12.9k21 gold badges85 silver badges169 bronze badges asked Jan 28, 2014 at 2:42 aankaank 111 bronze badge 4
  • This code is incomplete. What you have posted doesn't actually do anything. – s_ha_dum Commented Jan 28, 2014 at 5:19
  • i read on this www.colorlabsproject/tutorials/create-a-simple-wordpress-admin-panel-part-ii/ but i don't know how to emplementation on frontend, can you help me? – aank Commented Jan 28, 2014 at 5:38
  • what i mean before is, how to show all post in select category by panel themes, and now its work.thanks – aank Commented Feb 7, 2014 at 10:05
  • But what is your solution? So that other people can benefit? – s_ha_dum Commented Feb 7, 2014 at 13:22
Add a comment  | 

1 Answer 1

Reset to default 1

It looks like you are trying to model this on theme options code. You can't do that. That is backend code. As written, this question is very broad-- I am tempted to vote to close as "too broad"-- but I will offer bare bones code to get you started:

echo '<form method="post">';
  wp_dropdown_categories();
  echo '<input type="submit" name="catsearch" value="Submit" />';
echo '</form>';
if (isset($_GET['cat']) && ctype_digit($_GET['cat'])) {
  $qry = new WP_Query( 
    array(
      'cat' => (int)$_GET['cat'] 
    )
  );
  var_dump($qry);
}

You will need to consult the documentation for wp_dropdown_categories and WP_Query, and will probably need to do a bit a research on HTML forms and basic PHP.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744968766a4603839.html

相关推荐

  • theme development - How to show post from category select

    This code is in my functions.php:array( "name" => "Headline","type" => "sectio

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信