Support » Plugin: Wicked Folders » How is the order information stored

  • Resolved christer_f

    (@christer_f)


    I would like to create a shortcode for displaying links to the pages in a folder on the frontend and would like to use the ‘order’ information. How is this info stored? I thought I would find it in a post meta value, but didn’t.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author wickedplugins

    (@wickedplugins)

    Hi @christer_f,

    Are you referring to the order of a page within a folder when using the legacy folder browser?

    If so, the order is in fact stored in the postmeta table like you guessed and the meta key is constructed using this pattern:

    _wicked_folder_order__{folder_taxonomy_name}__{folder_id}

    The taxonomy name for page folders is wf_page_folders. So, assuming you have a page folder with an ID of 1, the meta key would be:

    _wicked_folder_order__wf_page_folders__1

    That being said, you can easily query pages by their folder-based sort order by setting the orderby parameter to wicked_folder_order. For example, to get all pages in folder 1 ordered by their sort order within the folder, you could do something like this:

    $pages = get_posts( array(
        'post_type'         => 'page',
        'posts_per_page'    => -1,
        'order'             => 'ASC',
        'orderby'           => 'wicked_folder_order',
        'tax_query' => array(
            array(
                'taxonomy'  		=> 'wf_page_folders',
                'field'     		=> 'term_id',
                'terms'     		=> 1,
    	    'include_children' 	        => false,
            ),
        ),
    ) );

    Note that wicked_folder_order only works when you include a tax_query that filters by a single folder since the order is specific to a single folder.

    I hope this helps! Let us know if you have questions.

    • This reply was modified 1 year, 7 months ago by wickedplugins. Reason: Corrected example meta key

    Thanks for you quick reply. Unfortunately it didn’t help 🙁
    First, I’m not sure what you mean by “the legacy folder browser”, but I don’t think that is important. More important: I don’t find any meta-keys at all that include “wicked” in postmeta. All the wicked folder information I can find is in the various wP_term… tables. I dumped out my database and looked for “wicked”, but nothing was found.

    I also tried to use the query you suggest, and I get the pages in the folder all right, but the order is random – a simple test to change ASC to DESC does not alter the order.

    Please notice that I do not use any dynamic folders for this.

    Plugin Author wickedplugins

    (@wickedplugins)

    Sorry @christer_f, I think I may have misunderstood your original question.

    When you say you “would like to use the ‘order’ information”, can you clarify what you mean by that?

    Hi again,

    Your question made me think! In fact the “order” is in fact a page attribute and not part of Wicked Folders! It is what is stored in the menu-order attribute of the page. So all I need to do is to use
    'orderby' => 'menu_order',
    instead of
    'orderby' => 'wicked_folder_order'
    in your example code and things work exactly as I wanted them to.

    Thanks a lot for your help!
    — christer

    Plugin Author wickedplugins

    (@wickedplugins)

    Great, glad you got what you needed!

    I’m going to mark this as resolved but, if you have any other issues or questions, please feel free to start another thread. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How is the order information stored’ is closed to new replies.