WordPress on IIS, Issues with WP_Query()
I have a client who has WordPress installed on IIS (php5, fast cgi) and is having an issue with my menu not showing up. Ironically, if he reverts to my previous theme version, the menu shows fine. Since I changed the query between the two versions, I'm wondering if someone might be able to spot the problem in the latter.
Previous version query appears to work fine:
global $post;
$cat=get_cat_ID('top-menu');
$catHidden=get_cat_ID('hidden');
$count=0;
$mypostsheader = get_posts(array('cat' => "$cat,-$catHidden",'showposts' => $cb2_current_count));
$mypostsheader2 = get_posts(array('cat' => "$cat,-$catHidden",'showposts' => -1));
$mypostsheadercount = count($mypostsheader2);
if($mypostsheader开发者_如何学JAVA)
{
$current_page = get_post( $current_page );
?>
However, the current version uses a bit different code logic to build the menu. This does not work under the same setup (but works on Apache fine)
$cat=get_cat_ID('top-menu');
$catHidden=get_cat_ID('hidden');
$myqueryTopMenu = new WP_Query();
$myqueryTopMenu->query(array(
'cat' => "$cat,-$catHidden",
'post_not_in' => get_option('sticky_posts')
));
$mypostsheadercount = $myqueryTopMenu->found_posts;
if($mypostsheadercount > 0)
{
global $post;
$mypostsheader = get_posts(array('cat' => "$cat,-$catHidden",'showposts' => $cb2_current_count));
$current_page = get_post( $current_page );
?>
I can't see how IIS is affecting this - are you sure both environments are running the same WordPress version?
I also recommend using posts_per_page
over showposts
- as mentioned in the documentation, showposts
is deprecated, and could be completely removed in the near future.
精彩评论