Support » Themes and Templates » function is_page() block current_page_item

  • Resolved Cherubin13

    (@cherubin13)


    Hello,

    I have a probleme, i would like to create a menu with 3 specific page, number 1,2,3.
    First i have this

    <?php wp_list_pages('depth=1&sort_column=menu_order&title_li='); ?>

    But if o create more pages, it’s not ok, because there are in the menu.

    So, i look the codex and see the parameter “include”, but it’s not ok too.

    <?php wp_list_pages('include=1,2,3&depth=1&sort_column=menu_order&title_li='); ?>

    Only one page is showed.

    I try even with exclude parameter, in adding all new pages, but doesn’t great…

    So, i think to put my menu in solid url, but i want keep the parameter css current_page_item, so i do this :

    <ul>
    
    				<?php if ( is_page(propos) ) { ?>
    
    				<li class="page_item"><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    				<li class="current_page_item"><a href="http://www.mywebsite.com/a-propos/">Préface d’InfoComPub.fr</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/definition-de-la-publicite/">Définition de la Publicité</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/contact/">Contact</a></li>
    
    				<?php } else if ( is_page(publicite) ) { ?>
    
    				<li class="page_item"><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/a-propos/">Préface d’InfoComPub.fr</a></li>
    				<li class="current_page_item"><a href="http://www.mywebsite.com/definition-de-la-publicite/">Définition de la Publicité</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/contact/">Contact</a></li>
    
    				<?php } else if ( is_page(contact) ) { ?>
    
    				<li class="page_item"><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/a-propos/">Préface d’InfoComPub.fr</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/definition-de-la-publicite/">Définition de la Publicité</a></li>
    				<li class="current_page_item"><a href="http://www.mywebsite.com/contact/">Contact</a></li>
    
    				<?php } else { ?>
    
    				<li class="current_page_item"><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/a-propos/">Préface d’InfoComPub.fr</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/definition-de-la-publicite/">Définition de la Publicité</a></li>
    				<li class="page_item"><a href="http://www.mywebsite.com/contact/">Contact</a></li>
    
    				<?php } ?>
    
    			</ul>

    But the current_page_item isn’t attributed correctly…

    Help me please…

    Thanks a lot

Viewing 2 replies - 1 through 2 (of 2 total)
  • stvwlf

    (@stvwlf)

    Hi

    Are you aware that the numbers 1, 2, 3 refer to the PAGE ID #, not the order you want the pages in or the order they are displaying on the page edit list?

    When you are on the page edit list page, point at the name of one of the pages. While pointing, look at the browser status bar in the extreme lower left of the browser window. You will see a URL appear there. The last part of the URL, on the right, is the ID # of the page you are pointing at.

    When you get all 3 of the page ID #s for the pages you want, put them in the
    'include=1,2,3& line instead of 1, 2, 3. More than likely this will solve your problem.

    Cherubin13

    (@cherubin13)

    You’re a genius… I am really stupid to have not thought of that…

    Thanks a lot!!! 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘function is_page() block current_page_item’ is closed to new replies.