Calling a Category w/PHP
This is a PHP problem in WordPress while using a cu开发者_JAVA百科stom theme options panel. I asked it on the WordPress site, but nobody could give me the right answer.
to_cat_home calls a category the user has selected from a theme options panel, to_count_home calls a number of posts the user has selected.
The problem is the posts_per_page works but the cat= simply doesn't.
On the archives pages the number of pages generated is determined by the basic WordPress settings, rather than the user selected number.
<?php
$cat = get_option('to_cat_home');
$per_page = get_option('to_count_home');
query_posts("cat=${cat}&posts_per_page=${per_page}&paged=".$paged);
if (have_posts())
?>
In my functions:
array( "name" => "Homepage featured category",
"desc" => "Choose a category from which featured posts are drawn",
"id" => $shortname."_cat_home",
"type" => "select",
"options" => $wp_cats,
"std" => "Choose a category"),
You should use
<?php
query_posts("cat={$cat}&posts_per_page={$per_page}&paged=".$paged);"
?>
精彩评论