开发者

How do I create a custom loop in wordpress that excludes categories listed in theme options

开发者 https://www.devze.com 2022-12-23 16:01 出处:网络
I have a custom loop that excludes categories using this code: query_posts(array(\'category__not_in\' => array(2,6)));

I have a custom loop that excludes categories using this code:

query_posts(array('category__not_in' => array(2,6)));

Instead of specifying the categories to 开发者_开发知识库exclude in the code, I'd like to be able to set the option in my custom theme options menu. The code to call the option is get_option('ex_cats');. How do I call this in my query_posts statement?


how about this query_posts(array('category__not_in' => array(get_option('ex_cats'))));

or $cats_id = get_option('ex_cats'); query_posts(array('category__not_in' => array($cats_id)));

i assume get_option('ex_cats') will return a string value.

0

精彩评论

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