• Hello everybody,

    I haven’t used WordPress for a while so most of the 2.x features are new to me, please have a little bit patience with me, i try my best.

    Since sunday I am working on a website based on WordPress and the Thematic theme, now I need a custom pages navigation and would like to know how I should realise it.

    The navigation will be placed in the Sidebar and should only display 2nd and 3rd level Pages, because I don’t want to hack the WP core my approach is to create the navigation as a new custom widget. Is there an easier way and how do I exclude all other Levels?

    Also I just want to display the 2nd and 3rd level Pages of the current Parent 1st level Page, all other pages should be hidden.

    If there are any questions because you can not understand my english I am happy trying to explain myself in another way.

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter hbhb

    (@hbhb)

    Thanks, that’s what i was looking for, although i will need to change the format! For the case i need further help I leave this topic on “not resolved” for now, so I do not have to explain the situation again!

    Thread Starter hbhb

    (@hbhb)

    The code you gave me worked fine by itself in the sidebar file of my template but now that I created a plugin/widget and use the code in there the variable $content stays empty, does any other code has to be executed first before this function returns values?

    Thread Starter hbhb

    (@hbhb)

    Full error description:

    When I include that Code snippet into my Plugin / widget the variable $post->ID stays empty / does not return any values!

    Error Message

    Notice: Undefined variable: post
    Notice: Trying to get property of non-object

    At wich point can I start using the variable post and how can I get it working in the Plugin?

    How about using global $post;

    Thread Starter hbhb

    (@hbhb)

    and how can I make $post global at the right position without hacking the wp code?

    Thread Starter hbhb

    (@hbhb)

    I wont use global and until I find a way I will put my code in the Sidebar directly!

    These work just fine in sidebar.php (using WordPress Default theme)

    echo 'this is the current post id ' . $post->ID;
    echo 'this is current page id ' . get_query_var('page_id');

    Thread Starter hbhb

    (@hbhb)

    I have my Code snippet in my sidebar now, it works fine as long as I am viewing a 1st level page, but it can not display the pages when I am in a child level, because then it wants to display the childs of the current child page:

    $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');

    How can I either display “brother_of” pages or find out the ID of the parent?

    Thread Starter hbhb

    (@hbhb)

    I found following as approach, how can I include the parent line

    <?php $args = array(
    ‘child_of’ => 0,
    ‘sort_order’ => ‘ASC’,
    ‘sort_column’ => ‘post_title’,
    ‘hierarchical’ => 1,
    ‘exclude’ => ,
    ‘include’ => ,
    ‘meta_key’ => ,
    ‘meta_value’ => ,
    ‘authors’ => ,
    ‘parent’ => -1,
    ‘exclude_tree’ => ,
    ‘number’ => ,
    ‘offset’ => 0 ); ?>

    Thread Starter hbhb

    (@hbhb)

    Thread already moved to page 3. How can I find out the post ID of the parent page? Tried many versions of the code out of my last two posts.

    <?php
    $pages = get_pages('sort_column=post_date&sort_order=desc');
    foreach($pages as $page) {
    //echo "<pre>"; print_r($page); echo "</pre>";
    echo 'page parent id ' . $page->post_parent;
    }
    ?>

    If you are doing a multi-level heirarchy and going several pages deep I’ve got a short tutorial that might help as well: https://www.vsellis.com/wordpress-how-to/wordpress-page-navigation-context-sensitive/

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Custom Page Navigation’ is closed to new replies.