WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [AutoNav] using sort_column parameter to display random order (14 posts)

  1. thomaspayne
    Member
    Posted 3 years ago #

    is it possible to sort pages in a random order?

    using the AutoNav plugin and trying to display all the page thumbnails in a random order.

    anybody know if this is possible?

  2. wlindley
    Member
    Posted 3 years ago #

    Try using version 1.3.0 with the parameter: order="rand"

  3. thomaspayne
    Member
    Posted 3 years ago #

    hey wlindley, thanks for getting back to me.

    tried your recommendation but with no joy.

    wondered if you had any more thoughts? would be super useful if there was a way to display in random.

  4. wlindley
    Member
    Posted 3 years ago #

    The order="rand" parameter currently randomizes attachments and posts but not child pages... you want the child pages in random order? That seems odd to me... not impossible, but wouldn't that make the site difficult to navigate?

  5. thomaspayne
    Member
    Posted 3 years ago #

    yeah its to display projects, so that no work is favoured by any sort of order. seemed like the most egalitarian way of presenting the child pages.

    also think it would give a really dynamic feel if the child pages could rearrange their order on each refresh, so the parent page would always look different.

    i'd be incredibly grateful if you or anyone else could provide any sort of advice or assistance on randomising the order!

  6. thomas_n
    Member
    Posted 3 years ago #

    It's really easy.

    In the plugin code, look for the function

    function get_subpages ($attr)

    Then near the end of the function add this:

    // Existing code ...
    if (count($pages) == 0) {
        return;
      }
    // Add this
      if ($attr['order']=='rand')
      {
    	shuffle($pages);
      }
    // Rest of existing code
      return get_pics_info($attr, $pages);

    Did the trick for me (for exactly the same application ;-)

  7. thomaspayne
    Member
    Posted 3 years ago #

    doesn't seem to be working for me. is there anything else i need to set as well?

  8. thomaspayne
    Member
    Posted 3 years ago #

    http://thomasjwpayne.com/dbuckingham/

    ...is the site im working on. the order might seem random at first but i've got the parameter set to menu_order which is why 'test 3' is top of the list.

  9. thomas_n
    Member
    Posted 3 years ago #

    thomaspayne asked me:

    doesn't seem to be working for me. is there anything else i need to set as well?

    Well, not that I know of. I use the following shortcode in the page:

    [autonav display="images" pics_only="1" order="rand"]

    This page changes the order each time it loads. Other pages (without the order parameter) show the pages in the defined fixed order.
    This works for me, can't show it (yet) because the site is not open to the public (yet).

  10. thomaspayne
    Member
    Posted 3 years ago #

    brilliant! got it working! many thanks.

  11. thomaspayne
    Member
    Posted 3 years ago #

    however, does seem to be occasionally missing off one of the child pages when i load the page. any thoughts?

  12. thomas_n
    Member
    Posted 3 years ago #

    No idea, I currently have 9 child pages and all of them are loading fine.

  13. wlindley
    Member
    Posted 3 years ago #

    Thanks, thomas_n. Added that patch to v1.3.1.

  14. locworks
    Member
    Posted 3 years ago #

    I'm using [autonav display="images" count="3" order="rand"] as a "Random products" gallery for my online shop. The more I try things out, the more I realise how useful your plugin is.

Topic Closed

This topic has been closed to new replies.

About this Topic