News

Default sort list for every new Site in your WordPress MultiSite environment

WordPress MultiSite environment is a great way to create a network of sites, easily managed from a common dashboard. The Advanced Post Types Order plugin is fully compatible with MultiSite set-up, it can be activated either on punctual site or network wide. (more…)

Customize sorting for products within a customer Order

Within a WooCommerce buyer Order, the products are being sorted / displayed in the way they where placed in the cart. Unfortunate WooCommerce does not provide any support through which such sorting can be changed.

woocommerce-sort-products-within-customer-order
(more…)

How to expand / narrow a sort settings within admin interface

The Advanced Post Types Order plugin include quite many options to cover up all possible scenarios. For that reason the sort settings admin interface it’s long, depending on monitor resolution it may not fit within a full screen size so the scroll need to be used to access all options.

Since the actual sorting interface is positioned under the Sort Settings area, it may be a bit annoying to keep scroll down the page until that section. A nice functionality is the possibility to collapse / expand the settings area making the actual sort interface visible right from the page load.
(more…)

Ignore sort apply for certain query on Post Types Order

This replaced the deprecated filter pto/posts_orderby

The free WordPress plugin Post Types Order is already a “must have” code on any website. Control any post sorting through a nice and easy to use interface.

When Autosort is ON, the sorting is applied to all queries that match the post type. It can be forced by either using the ignore_custom_sort argument within the query , or by using a filter pto/posts_orderby/ignore which can be placed within any code, preferable on theme functions.php

Example
The following code ignore the sort apply for any query which include ‘reports’ post type

	add_filter('pto/posts_orderby/ignore', 'theme_pto_posts_orderby', 10, 3);
    function theme_pto_posts_orderby($ignore, $orderBy, $query)
       {
           if( (! is_array($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'reports') || 
                   (is_array($query->query_vars)   &&  in_array('reports', $query->query_vars)))
                   $ignore = TRUE;
           
           
           return $ignore;
       }

Apply post type Archive order for all taxonomies / categories

The Advanced Post Types Order plugin is very flexible in functionality. In certain situations, individual sort for each taxonomy terms (categories) is not required, but instead Archive order is needed to apply on all other sections.

The following example return the archive order for any query that match the post type array. The apto/query_match_sort_id filter is being used:
(more…)

Hide Sort Settings interface for certain administrator role users

The Sort Settings interface is available by default only to administrator role users. There are situations when sort settings need to be available only for certain users. The apto/wp-admin/reorder-interface/view-settings-capability filter help on that matter.

The following example hide the sort settings interface if logged-in user is not ID 1 or 2 or 3. This can be extended to check against username, user meta data etc. If not match it should return a capability that current user does not support.

add_filter('apto/wp-admin/reorder-interface/view-settings-capability', 'view_settings_capability');
    function  view_settings_capability($capability)
        {
            $user_ID = get_current_user_id();
            
            if(!in_array($user_ID, array(1, 2, 3)))
                $capability =   '_sort_capability_';
            
            return $capability;   
        }

Automatic Sort for all new future created categories

Sorting post types within Taxonomies Terms become an easy task through Advanced Post Types Order plugin. Further more the Automatic Sort functionality put the code on work and make the sort for you per predefined criteria https://www.nsp-code.com/advanced-post-types-order-description-and-usage/manual-automatic-sorting-type-usage/

The Automatic Sort is an efficient way to improve site management productivity by reduce redundant sort actions. It takes arguments for a particular taxonomy terms and auto-sort any objects inside (previously created or future ones) by that criteria.

What if Automatic Sort is needed to be created automatically once a new taxonomy term (like categories) has been created? This is an easy task, using the Advanced Post Types Order plugin API’s.
(more…)

Autosort a Category by posts Featured Image Title

The Automatic Order functionality along with Custom Function it’s a very powerful tool to customize the sort of a give area by very specific criteria. As specified at https://www.nsp-code.com/applying-automatic-order-for-a-sort-through-a-user-function-callback/ the filter return a list of all posts within the section / query on which different operations can apply.
(more…)

Pagination on AJAX Sort List Update

For very large list, it can be a challenge to save an order list. Something this can take a while, on certain hosts it can be stopped from execution returning an 500 server error. The main cause for this is a php environment variable called Maximum Execution Time. This is generally set for 30 seconds.
When Pagination is set for Advanced Post Types Order plugin, the timeouts are no longer a problem, the sort list save job is split into small chunks to allow server to process the data.

Pagination on AJAX Sort List Update - progress

Additionally, a progress data is being show, the current chunk page out of total jobs.

Applying multiple order criteria for Automatic Order through Fallback functionality

The Advanced Post Types Order plugin include an easy way to automatically sort objects of a list (e.g. post type archive, category list, mix of post types and taxonomies terms etc) through a powerful functionality called Automatic Order. This will auto update sort for objects on front site.

advanced-post-types-order-automatic-sort-interface-example

(more…)