WordPress.org

Ready to get started?Download WordPress

Forums

current_page_item a isn't working (10 posts)

  1. xmatter
    Member
    Posted 3 years ago #

    #menu {width:900px;padding:3px 0px 0px; margin:0px}
    #menu ul {padding:0; margin:0px; list-style:none; text-align:right; font-size:12px}
    #menu li {display:inline-block; padding:4px 0px }
    #menu li a {color:#010413; text-decoration:none; padding:4px 10px; margin:0px;}
    #menu li a:hover {color:white; text-decoration:none; background:#010413}
    #menu li.current_page_item a {background:yellow;color:green}

    the current page link is not working, any ideas?

  2. David Gard
    Member
    Posted 3 years ago #

    I believe you are looking for current_page_parent rather than current_page_item(), which is a function you can call that returns either true or false. Also, not sure that background works with a, but not 100% sure on that.

    Thanks.

  3. xmatter
    Member
    Posted 3 years ago #

    <div id="menu">
        <ul>
         <li><a href="http://www.sample.com/?page_id=4">home</a></li>
         <li><a href="http://www.sample.com/?page_id=8">sign up</a></li>
         <li><a href="http://www.sample.com/?page_id=2">about us</a></li>
         <li><a href="http://www.sample.com/?page_id=16">contact us</a></li>
        </ul>
       </div>

    here is the code that is in my header.php

  4. David Gard
    Member
    Posted 3 years ago #

    Is that hardcoded? If so, then the CSS class .current_page_parent will never be used.

    wp_list_pages() will list your pages and add the correct classes that are needed, whcih should then pick up your desired styling as above.

    Thanks.

  5. xmatter
    Member
    Posted 3 years ago #

    ok, thanks! i didn't want to use wp_list_pages but i guess it will. i'll just have to add the "include" arg

    thanks agains

  6. David Gard
    Member
    Posted 3 years ago #

    No problem - WP list pages is very powerful. You can if you wish use it like this -

    $pages = wp_list_pages('echo=false');

    - so that the pages are not displayed by the function, but rather placed in a string. You can then manipulate that string as you please, should the need arise, before using echo $pages; - that way you get the power and the compatibility of the wp_list_pages() function and the convieniance and flexibility of a string.

  7. xmatter
    Member
    Posted 3 years ago #

    since i have to use wp_list (which worked, so thanks) how to i specify the order in which the links display?

    using this:

    <?php wp_list_pages('title_li=&include=4,8,2,16');?>

    it displays the pages out of order. is there a way to specify an order and not alpha, or by page number or post title, but by the order from the above post. you can see the page id's and names.

    Thanks

  8. David Gard
    Member
    Posted 3 years ago #

    Check out the WordPress Codex for wp_list_pages(), which will explain what all the arguments do (look for 'sort_column' and 'sort_order' in particular).

    Also, check out the 'pageMash' plugin. It offers an AJAX interface that allows you to drag and drop the pages in to any order you wish (look under the 'Pages' menu in the admin area), so then you don't have to worry about the arguments.

    Thanks.

  9. xmatter
    Member
    Posted 3 years ago #

    oh man, completely forgot about the page order number within each page. I really appreciate all your help and quick responses. setting page order worked as desired.

  10. David Gard
    Member
    Posted 3 years ago #

    I'd still recommend the 'pageMash' plugin, it will save you so much time if you ever need to rearrange the pages, or even add one slap bang in the middle!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.