WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] function is_page() block current_page_item (3 posts)

  1. Cherubin13
    Member
    Posted 5 years ago #

    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

  2. stvwlf
    Member
    Posted 5 years ago #

    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.

  3. Cherubin13
    Member
    Posted 5 years ago #

    You're a genius... I am really stupid to have not thought of that...

    Thanks a lot!!! :D

Topic Closed

This topic has been closed to new replies.

About this Topic