开发者

Calling a Category w/PHP

开发者 https://www.devze.com 2023-04-11 00:21 出处:网络
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.

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);"
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号