WP-CLI Commands for Advanced Post Types Order

Last updated on: October 9, 2026 5:27 am

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

Advanced Post Types Order (APTO) includes WP-CLI commands for inspecting and managing sorting configurations directly from the command line. This makes routine maintenance easier to automate and is particularly useful when working with remote servers, deployment scripts, or WordPress installations where administration through the dashboard is inconvenient.

Using WP-CLI, you can list configured sorts, inspect their settings and views, clear saved manual ordering, delete obsolete configurations, and clear APTO’s site cache.

All commands use the apto namespace:

wp apto <group> <command>

Run commands from the WordPress installation directory, with WP-CLI installed and APTO active. Make sure you are targeting the intended WordPress installation before performing maintenance, particularly when managing multiple sites.

Note: The commands available depend on your installed APTO version. The cache command is already available; the sort and view commands require their corresponding WP-CLI handlers to be included in the installed version.

Available commands

Command Description
wp apto cache clear Clears APTO’s site cache.
wp apto sort list Lists configured parent sorts.
wp apto sort get <sort-id> Displays a sort’s configuration.
wp apto sort view list <sort-id> Lists views belonging to a sort.
wp apto sort view get <view-id> Displays a view’s configuration.
wp apto sort view clear-order <view-id> Clears a view’s saved manual ordering.
wp apto sort delete <sort-id> Permanently deletes a sort and its views.
wp apto sort view delete <view-id> Permanently deletes an individual child view.

Replace <sort-id> and <view-id> with the corresponding numeric IDs. You can discover these IDs using the list commands before running commands that modify or delete data.

Clearing the cache

wp apto cache clear

wp apto cache clear

Clears APTO’s site cache through APTO_functions::site_cache_clear().

Use this command when you need to clear cached APTO data during maintenance or after configuration changes. Clearing the cache does not delete sort configurations, views, or their saved manual ordering.

Inspecting sorts

A sort represents the main sorting configuration in APTO. It defines the overall sorting setup, which may contain one or more views depending on the selected view model.

wp apto sort list

wp apto sort list

Lists the configured parent sorts, including their IDs, titles, and view types.

A parent sort is an apto_sort post without a parent post. The returned IDs can be used to inspect individual configurations or list their associated views.

For example, start with this command when you need to find a sorting configuration before performing further operations.

wp apto sort get <sort-id>

wp apto sort get 123

Displays the configuration of parent sort 123, including its stored settings, applicable post types, view model, and other configuration details.

Use this command to verify a sort’s settings before modifying or deleting it. The supplied ID must identify a valid parent apto_sort post.

Inspecting views

A view defines where and how a sort is applied. Depending on the configuration, a view can target an archive, a taxonomy term, a language, or another supported context.

APTO supports two view models:

  • Simple sort: The parent sort is also its only view. The sort ID and view ID are identical.
  • Multiple sort: The parent sort contains separate child views. Each child can define a different sorting configuration, such as for an archive or a specific taxonomy term.

Understanding this distinction is important when using commands that operate on individual views.

wp apto sort view list <sort-id>

wp apto sort view list 123

Lists the views associated with parent sort 123, including each view’s ID, order type, and selection type.

For a simple sort, the sort itself represents the only view. For a multiple sort, the command lists its child views.

Use this command to identify the correct view ID before inspecting, clearing, or deleting an individual view.

wp apto sort view get <view-id>

wp apto sort view get 456

Displays the configuration of view 456 through APTO_functions::get_sort_view_settings().

Depending on the view configuration, the output includes details such as:

  • Order type: manual, auto, or ai-sort.
  • View selection: Archive or taxonomy.
  • Taxonomy and term: The targeted taxonomy context, when applicable.
  • Language: The language associated with the view, when configured.
  • Automatic sorting settings: Configuration relevant to automatic ordering, when applicable.

For a simple sort, pass the parent sort ID because the parent and view share the same ID.

Managing saved manual ordering

wp apto sort view clear-order <view-id>

wp apto sort view clear-order 456

Removes the saved manual-order entries associated with view 456.

The command uses the following APTO method:

APTO_functions::delete_sort_list_from_table( $view_id );

This operation clears the view’s saved ordering data from APTO’s sort-list table. It does not delete the sort or view, reset their configuration, or modify the WordPress posts’ menu_order values.

The command should only be used with views configured for manual ordering. Views using automatic or AI-based ordering should not be treated as manually ordered views.

Use this command when you need to remove an existing manual order and allow the view to be reordered again, without removing the underlying configuration.

Deleting views and sorts

Deletion commands permanently remove configuration data. Inspect the target configuration before proceeding, and make a database backup before performing destructive maintenance.

wp apto sort view delete <view-id>

wp apto sort view delete 456

Permanently deletes a single child view while retaining its parent sort. The view’s associated saved ordering data should also be removed.

This command is intended for individual views belonging to a multiple sort. It must not be used to delete a multiple-sort parent.

For a simple sort, the parent is also the view. Delete it using wp apto sort delete <sort-id> instead.

wp apto sort delete <sort-id>

wp apto sort delete 123

Permanently deletes parent sort 123, including its child views and the saved ordering rows associated with those views.

The deletion process should follow APTO’s existing administrative deletion flow: remove the child views and their associated sort-list entries first, then permanently delete the parent sort.

Before deleting a sort, review its configuration and associated views:

wp apto sort get 123
wp apto sort view list 123

Verify that the selected sort and views are no longer needed. Deletion removes the configuration rather than merely disabling sorting, so this command should be used with care.

Recommended workflows

Find and inspect a sorting configuration

Start by listing the existing sorts, then inspect the configuration and its views.

wp apto sort list
wp apto sort get 123
wp apto sort view list 123
wp apto sort view get 456
Clear a view’s manual ordering

Identify the view and confirm that it uses manual ordering before clearing its saved order.

wp apto sort view list 123
wp apto sort view get 456
wp apto sort view clear-order 456
Remove an obsolete view or sort

Review the configuration before running a deletion command.

# Inspect the parent sort and its views.
wp apto sort get 123
wp apto sort view list 123

# Delete one child view.
wp apto sort view delete 456

# Or, when the entire configuration is no longer needed:
wp apto sort delete 123

Choose the view deletion command when you need to retain the parent sort. Use the sort deletion command when the entire sorting configuration and its associated views should be removed.

Clear APTO’s cache
wp apto cache clear

Use this independently when cache maintenance is required. It does not replace the commands for managing sorts, views, or manual ordering.

Summary

APTO’s WP-CLI commands provide direct access to essential sorting maintenance tasks. You can inspect sort configurations, identify their views, remove saved manual ordering, delete obsolete configurations, and clear the site cache from the terminal.

These commands are also suitable for scripted administration, helping developers manage APTO configurations without relying exclusively on the WordPress dashboard.