• Resolved randski

    (@randski)


    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter randski

    (@randski)

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

    Thanks.

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

    https://themecorp.com/themes/blixed/

    Sadish

    Thread Starter randski

    (@randski)

    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?

    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

    Thread Starter randski

    (@randski)

    That worked, thank you very much.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Blix theme header question’ is closed to new replies.