Forums
Home / Fixing WordPress / is_page conditional not work in sidebar.php
(@alias75)
16 years, 2 months ago
Hi man, i made some pages, in this page i would like show only some post. Then i insert this code in page.php
<?php } elseif ( is_page('page name') ) { ?> <?php $query= 'cat=38&orderby=date&order=ASC'; query_posts($query); ?> <?php while ( have_posts() ) : the_post() ?> <?php if (in_category('30,31,32,37,1,34,33,36,29,2,7,23,9,5,11,18,16,22,20,15,21,25,6,26,19,17,14,24,13,12,10,27,28,8'))continue; ?>
at end of while i insert
<?php $wp_query->is_page = true; ?>
and it’s works very well. Now when i change the sidebar.php for show the categories for this page, the conditional elseif do not work never!
<?php } elseif ( is_page('page name') ) { ?> <li id="categories"> <h3><?php _e('Name tab', 'sandbox'); ?></h3> <ul> <?php wp_list_cats('sort_column=name&hierarchical=1&exclude=1,30,33,34,36,29,2,8') ?> </ul> <?php } else { // this works ever ?>
Have you some suggest? This’s a WP bug?
thanks
ps. i’m apologies for my english.
i’m solved at end of while will must be insert:
<?php $wp_query->is_page = true; $wp_query->queried_object->ID = $page_id; $wp_query->queried_object_id = $page_id; ?>