WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Blix theme header question (6 posts)

  1. randski
    Member
    Posted 6 years ago #

    Okay, third try. I have no idea why the topic keeps disappearing after I hit post. Anyway.

    I'm using the Dark Blix theme on my site, and I was having a problem displaying links to page in the header, until I came across this post. When I replaced the following code I had in header.php:

    <li<?php if (is_home()) echo " class=\"selected\""; ?>>">Home
    <?php
    $pages = BX_get_pages();
    if ($pages) {
    foreach ($pages as $page) {
    $page_id = $page->ID;
    $page_title = $page->post_title;
    $page_name = $page->post_name;
    if ($page_name == "archives") {
    (is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="selected"':$selected='';
    echo "<li".$selected.">Archives\n";
    }
    elseif($page_name == "about") {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected.">About\n";
    }
    elseif ($page_name == "contact") {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected.">Contact\n";
    }
    elseif ($page_name == "about_short") {/*ignore*/}
    elseif ($page_id == "11") {/*ignore*/}
    elseif ($page_id == "12") {/*ignore*/}
    elseif ($page_id == "13") {/*ignore*/}
    elseif ($page_id == "14") {/*ignore*/}
    elseif ($page_id == "182") {/*ignore*/}
    elseif ($page_id == "16") {/*ignore*/}
    elseif ($page_id == "190") {/*ignore*/}
    elseif ($page_id == "193") {/*ignore*/}
    elseif ($page_id == "184") {/*ignore*/}
    elseif ($page_id == "241") {/*ignore*/}
    elseif ($page_id == "194") {/*ignore*/}
    elseif ($page_id == "22") {/*ignore*/}
    elseif ($page_id == "242") {/*ignore*/}
    elseif ($page_id == "243") {/*ignore*/}
    elseif ($page_id == "244") {/*ignore*/}
    elseif ($page_id == "245") {/*ignore*/}
    elseif ($page_id == "246") {/*ignore*/}
    elseif ($page_id == "247") {/*ignore*/}
    elseif ($page_id == "248") {/*ignore*/}
    else {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected.">$page_title\n";
    }
    }
    }
    ?>

    With this code from that post:

    <li<?php if (is_home()) echo " class=\"current_page_item\""; ?>>"><?php _e('Home'); ?>
    <?php wp_list_pages("title_li=&depth=-1&sort_column=menu_order")
    ?>

    The navigation links worked fine, except ALL of them were displayed, instead of just a select few. As in, all the pages that I had on ignore before show up on the nagivation bar, which is something I don't want. Is there a way to incorporate the elseif ($page_id == "#") {/*ignore*/} part into the new code and keep those pages on ignore?

  2. randski
    Member
    Posted 6 years ago #

    Bumping because it's been a week and I still haven't found a solution to this problem.

    Thanks.

  3. sadish
    Member
    Posted 6 years ago #

    Take a look at my Blixed theme and see how it is being done using the wp_list_pages().

    http://themecorp.com/themes/blixed/

    Sadish

  4. randski
    Member
    Posted 6 years ago #

    The theme I'm using is a bit different from the normal Blix theme. You can take a look at the site here. If I download the theme you linked to, is the layout on my site going to change?

  5. sadish
    Member
    Posted 6 years ago #

    I dont intend you to use my theme. I just want you to take a look at the code and see how the top navigation is done using wp_list_pages.

    Anyway, let me give a different solution.

    try this.
    use the same code as suggested above.
    change this
    wp_list_pages("title_li=&depth=-1&sort_column=menu_order")
    to
    wp_list_pages("title_li=&depth=-1&sort_column=menu_order&exclude=11,12,13,14,182,16")

    Add as many page ids as you want, separated by commas.

    Sadish

  6. randski
    Member
    Posted 6 years ago #

    That worked, thank you very much.

Topic Closed

This topic has been closed to new replies.

About this Topic