Forums

Custom Page Navigation (14 posts)

  1. hbhb
    Member
    Posted 2 years ago #

    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

  2. MichaelH
    Volunteer
    Posted 2 years ago #

  3. hbhb
    Member
    Posted 2 years ago #

    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!

  4. hbhb
    Member
    Posted 2 years ago #

    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?

  5. hbhb
    Member
    Posted 2 years ago #

    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?

  6. MichaelH
    Volunteer
    Posted 2 years ago #

    How about using global $post;

  7. hbhb
    Member
    Posted 2 years ago #

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

  8. hbhb
    Member
    Posted 2 years ago #

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

  9. MichaelH
    Volunteer
    Posted 2 years ago #

    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');
  10. hbhb
    Member
    Posted 2 years ago #

    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?

  11. hbhb
    Member
    Posted 2 years ago #

    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 ); ?>

  12. hbhb
    Member
    Posted 2 years ago #

    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.

  13. MichaelH
    Volunteer
    Posted 2 years ago #

    <?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;
    }
    ?>
  14. vsellis
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic