WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to I change the 'Pages' dropdown? (23 posts)

  1. IestynR
    Member
    Posted 3 years ago #

    Hey.

    Does anyone have and information as to how I can go about changing the link 'Pages' that's on the top header, to just 'About'? Right now you have to go Pages>About to access our 'about' sections, I'd like it just to be 'About' up there.

    I'm using Cleanr template, and here's the site: http://www.thegallivantingjournals.co.uk:/blog/

    Thank you!

  2. IestynR
    Member
    Posted 3 years ago #

    Ah! Manage to change the Pages to 'About' - but is there any way to change the 'About' so that I don't have to go About>About? No dropdown, just click on About to go to that page?

  3. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Looks like your theme is using a custom Page dropdown. Have you tried looking in header.php for the code block that generates this dropdown?

  4. IestynR
    Member
    Posted 3 years ago #

    Hey again esmi.

    Yeah, I've been inside the header.php - this is how I managed to change to 'PAges' to 'About', but unfortunately, I have no idea what the code for a dropdown looks like. Any hints as to what it might be?

  5. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    It could be anything from a block og javascript to a function call. Drop a copy of header.php into the WordPress pastebin and post the pastebin url here. Perhaps someone will be able to spot the problem and suggest a solution.

  6. IestynR
    Member
    Posted 3 years ago #

    Awesome - thanks.

    Here's the patsebin result:

    http://wordpress.pastebin.com/HPcpR9Sa

    I just want to get rid of the Dropdown only on the 'About' on the Blog, and make the 'About' that's on the dropdown the only thing there, so you don't have to go About>About.
    Thanks

  7. IestynR
    Member
    Posted 3 years ago #

    As you can see - all I've done right now, is change the values on line 24 to 'About'.

  8. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    OK - what that bit of code is doing is listing all of your Pages. Assuming that your About page has an id of 2, the first task is to exclude it from the Pages menu and hide the Pages menu if you don't have any Pages except About. So try changing:

    <?php wp_list_pages('title_li=About'); ?>

    to:

    <?php if( wp_list_pages('title_li=&exclude=2&echo=0') ) wp_list_pages('title_li=Pages&exclude=2'); ?>

    Then you'll need to add in an essentially hard-coded link to your About page. So just above the new line, try adding:

    <?php
    $page_id = 2; // id of the About page
    get_page( $page_id );
    $page_title = $page_data->post_title;?>
    <li class="about"<a title="<?php echo $page_title;?>" href="<?php echo get_page_link($page_id);?>"><?php echo $page_title;?></a></li>

    The whole thing should look like:

    <?php
    $page_id = 2; // id of the About page
    get_page( $page_id );
    $page_title = $page_data->post_title;?>
    <li class="about"<a title="<?php echo $page_title;?>" href="<?php echo get_page_link($page_id);?>"><?php echo $page_title;?></a></li>
    <?php if( wp_list_pages('title_li=&exclude=2&echo=0') ) wp_list_pages('title_li=Pages&exclude=2'); ?>

    At least that's how it should work in theory, ;-)

  9. IestynR
    Member
    Posted 3 years ago #

    Heya - that's awesome that you've created the script for me, but unfortunately, it's taken away the 'About' link all together. How do I check if the About Page has an id of 2?

  10. IestynR
    Member
    Posted 3 years ago #

    Hey.

    Anyone got any other recommendations?

  11. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

  12. IestynR
    Member
    Posted 3 years ago #

    Thanks for the link esmi - you're correct, the post id is 2. HAve you got any idea why it wouldn't work?

  13. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Just realised - I messed up the list/link markup! :-( Try:

    <li class="about"><a title="<?php echo $page_title;?>" href="<?php echo get_page_link($page_id);?>"><?php echo $page_title;?></a></li>

  14. IestynR
    Member
    Posted 3 years ago #

    Nope :( Still no luck I'm afraid. Any other suggestions?

  15. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Have you checked the page source? Is anything being generated?

  16. IestynR
    Member
    Posted 3 years ago #

    The post id is 2 for the About page, but I've also changed the slug to 'about-us'.

    On the code above, you say, for example: get_page( $page_id ); should '$page_id' here be 'about-us'?

  17. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    No - it's the page's id - not its slug.

  18. IestynR
    Member
    Posted 3 years ago #

    Yeah, just viewed the source (I've just changed the code back to yours again for you to have a quick look at) and I thin it's being generated, here's what it says:

    <ul id="nav">
    <li class="about">

    Does that look ok to you? Is there something I'm missing for it not to be displaying anything?

  19. IestynR
    Member
    Posted 3 years ago #

    Woops, here's the Source:

    <ul id="nav">
      <li class="about"><a title="" href="http://www.thegallivantingjournals.co.uk/blog/about-us/"></a>
  20. IestynR
    Member
    Posted 3 years ago #

    Hmm, that's not displaying. I'll leve it up for a wee bit for you to see.

  21. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Ah - I can see the problem!

    Try:

    <?php
    $page_id = 2; // id of the About page
    $page_data = get_page( $page_id );
    $page_title = $page_data->post_title;?>
    <li class="about"><a title="<?php echo $page_title;?>" href="<?php echo get_page_link($page_id);?>"><?php echo $page_title;?></a></li>
    <?php if( wp_list_pages('title_li=&exclude=2&echo=0') ) wp_list_pages('title_li=Pages&exclude=2'); ?>
  22. IestynR
    Member
    Posted 3 years ago #

    Genius!!! Thank you so much esmi :) That worked a treat!!

    Thank you so much for your help on this, it's much appreciated. I seriously wouldn't have a clue how to do this. Thank you for your time :)

  23. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    You're very welcome. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic