Support » Plugin: Child Page Navigation » Don't show current page option?

  • vasvir

    (@vasvir)


    Hi your plugin was really useful for us. The two items that another user complains about were extremely useful from us

    Widget will now show sibling pages if there are no children and there are sibling pages

    Default sort order changed to the specified menu order in WordPress

    However there is a feature that is missing. The ability to exclude the current page from the list of navigation items. We had to hack it to perform that way:

    Here is the code to do it in case you would like to make this a proper option:

    — child-page-navigation.orig/child-page-navigation.php 2012-06-27 01:43:42.000000000 +0300
    +++ child-page-navigation/child-page-navigation.php 2012-11-20 15:30:00.062651844 +0200
    @@ -68,13 +68,15 @@

    echo "";
                     echo $after_widget;
                 }elseif($post -> post_parent) { // Show the sibling pages if there are no children
    -                if(count($siblings)) {
    +                if(count($siblings) > 1) {
                         echo $before_widget;
                         $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
                         if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
                         echo "
    <ul>";
                         foreach($siblings as $page){
    -                        echo "
    <li><a>ID)."'>".get_the_title($page->ID)."</a></li>
    ";
    +                        if ($page->ID != get_the_ID()) {
    +                            echo "
    <li><a>ID)."'>".get_the_title($page->ID)."</a></li>
    ";
    +                        }
                         }
                         echo "</ul>
    ";
                         echo $after_widget;

    http://wordpress.org/extend/plugins/child-page-navigation/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Here is the same patch forward ported to the new child-page navigation. Please include that feature at least as an option. It is not nice to have a navigation link to the current page…

    Index: child-page-navigation.php
    ===================================================================
    --- child-page-navigation.php   (revision 14435)
    +++ child-page-navigation.php   (working copy)
    @@ -62,10 +62,13 @@
    
                    $pages = get_pages($page_arr);
    
    -               if($post->post_parent && !count($pages))
    +               if($post->post_parent && !count($pages)) {
                            $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent;
                            $pages = get_pages($page_arr);
    -
    +                       if (count($pages) < 1)
    +                               return;
    +               }
    +
                    if(!count($pages))
                            return;
    
    @@ -76,8 +79,10 @@
    
                    echo "
    <ul>";
    
    -               foreach($pages as $page){
    -                       echo "
    <li><a>ID)."'>".get_the_title($page->ID)."</a></li>
    ";
    +               foreach($pages as $page) {
    +                       if ($page->ID != get_the_ID()) {
    +                               echo "
    <li><a>ID)."'>".get_the_title($page->ID)."</a></li>
    ";
    +                       }
                    }
    
                    echo "</ul>
    ".$args['after_widget'];

    edited – disregard my previous post. Was actually another topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Don't show current page option?’ is closed to new replies.