WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: AutoNav Graphical Navigation and Gallery Plugin] links to siblings? (10 posts)

  1. buskerdog
    Member
    Posted 4 years ago #

    I had a hard time fitting my question in the subject. Basically, this is a fantastic plugin but I'm looking to see if there's a way to do something with it:

    Let's say my page structure is:

    MAIN
     - ABOUT
     - BIO
     - FRIENDS

    I have thumbs for About, Bio and Friends appear at the bottom of Main, no problem. What I want is for the thumbs for About, Bio and Friends to appear on About, Bio and Friends as well, so that if you are in a child page you still have the links to the other "siblings" of the same parent.

    Is it clear? That would be awesome.

    Another thing that's not nearly as important would be a php code that you could put in your theme rather than putting something in the posts themselves... That would be great.

    Thanks!

  2. buskerdog
    Member
    Posted 4 years ago #

    I just found a way to SORT OF do this:

    postid="123" Displays images or subpages attached to the page or post with the given ID, instead of the current page or post.

    This way you can force the parent's children thumbs in to each child. I'll leave this thread as unresolved in case the plug-in's author wants to chime in but this feature does solve the problem, essentially.

    Having a theme-friendly bit of php would still be sweet though...

  3. wlindley
    Member
    Posted 4 years ago #

    Good idea... I am preparing a v1.2.3 which will have optional parameters:

    [autonav display="images,siblings"]

    or as a list:

    [autonav dispaly="list,siblings"]

    This normally does not include the current page, but you can include that too:

    [autonav display="images,siblings,self"]

    As for template use, the code is in:

    http://wordpress.org/support/topic/322515

  4. buskerdog
    Member
    Posted 4 years ago #

    fab, fab, fab!

  5. wlindley
    Member
    Posted 4 years ago #

    Version 1.2.3 should be downloadable here momentarily.

  6. buskerdog
    Member
    Posted 4 years ago #

    Thanks! I added this to the functions.php file in my theme:

    function is_subpage() {
    	global $post;                                 // load details about this page
            if ( is_page() && $post->post_parent ) {      // test to see if the page has a parent
                   $parentID = $post->post_parent;        // the ID of the parent is this
                   return $parentID;                      // return the ID
            } else {                                      // there is no parent so...
                   return false;                          // ...the answer to the question is false
            };
    };

    to get the is_subpage() conditional tag

    And then put this in my page.php

    <?php if ( is_subpage() ): ?><?php print autonav_wl_shortcode(array('display'=>'images,siblings,self','pics_only'=>'1')); ?>
    	<?php else : ?><?php print autonav_wl_shortcode(array('display'=>'images','pics_only'=>'1')); ?>
    	<?php endif ; ?>

    Works so far!

  7. buskerdog
    Member
    Posted 4 years ago #

    oops, spoke too soon. On pages with no subpages I get this error:
    Warning: Invalid argument supplied for foreach() in /home/xxxx/public_html/wp/wp-content/plugins/autonav/autonav-wl.php on line 479

  8. buskerdog
    Member
    Posted 4 years ago #

    Alright this uses get_children to check if the page has any children before running the autonav on it:

    <?php if ( is_subpage() ): ?><?php print autonav_wl_shortcode(array('display'=>'images,siblings,self','pics_only'=>'1')); ?>
    	<?php else : ?><?php if ( get_children( $post->ID ) ) : ?><?php print autonav_wl_shortcode(array('display'=>'images','pics_only'=>'1')); ?><?php endif ; ?>
    	<?php endif ; ?>
  9. wlindley
    Member
    Posted 4 years ago #

    Version 1.2.4 resolves the above case (buskerdog, you should be able to remove the extra php), and indeed the general case where no output is produced.

    buskerdog -- If you agree this completes your suggestion, please mark this thread Resolved, and many thanks!

  10. buskerdog
    Member
    Posted 4 years ago #

    Indeed! Great work!

Topic Closed

This topic has been closed to new replies.

About this Topic