How to Sort WordPress Posts ( Custom Post Types ) Order with Admin Columns Pro Filters and ACF
When managing a WordPress website with complex content and custom post types, having efficient ways to filter and sort your posts is crucial. The Advanced Post Types Order plugin allows you to customize post ordering, while Admin Columns Pro helps you enhance the admin dashboard by adding custom filters and columns. In this article, we’ll walk through how to sort posts using Advanced Post Types Order while applying a filter from Admin Columns Pro, specifically based on a taxonomy field created using Advanced Custom Fields (ACF).
This combination of plugins is extremely useful if you’re working with custom post types that require dynamic ordering and filtering based on custom fields. Here, we will use a taxonomy field from ACF as the filter criteria, and demonstrate how to sort posts by specific terms within the taxonomy.
Step 1: Create an ACF Field with Taxonomy Field Type
To get started, you need to create a taxonomy field using Advanced Custom Fields (ACF). This field will serve as the base for the filter.
Directions:
- Navigate to ACF: In the WordPress dashboard, go to the Custom Fields section provided by ACF.
- Create a New Field Group: Create a new field group and add a field.
- Set Field Type: When adding the new field, set the Field Type as Taxonomy (as shown in the image you uploaded labeled “acf-field-setup.png”).
- Taxonomy Selection: In the “Taxonomy” dropdown, select the taxonomy you want to use. For example, you can select “Country” if you are sorting posts based on countries.
- Save Terms and Load Terms: Make sure to enable the Save Terms and Load Terms options. This will ensure that the taxonomy terms are saved and loaded properly with the posts. When you save terms, it updates the appropriate WordPress tables, making the data accessible for sorting and filtering.
These steps will add a new taxonomy field to your post type, which we will later use as a filter in Admin Columns Pro.
Step 2: Setup a Custom Column in Admin Columns Pro
Next, we will configure Admin Columns Pro to add the new ACF field as a filter in the WordPress admin dashboard for the post type you want to manage.
Directions:
- Open Admin Columns Pro Settings: From the WordPress dashboard, navigate to Admin Columns Pro.
- Choose the Post Type: Select the post type (or custom post type) where you want to apply the filter. This could be standard posts, pages, or any custom post type you have created.
- Add a New Column: Click to add a new column for that post type.
- Select the ACF Field: In the Type dropdown, select the ACF field you created earlier, in this case, the taxonomy field. As seen in the image you uploaded (admin-columns-filter-setup.png), choose the taxonomy field (e.g., “Country”) from the Advanced Custom Fields options.
- Save the Column Setup: After selecting the field, save the configuration. This will add the new column to your post type’s list in the admin dashboard.
Now, your new ACF taxonomy field is available as a filter on the admin post list.
Step 3: Apply the Filter and Sort Posts
Once you’ve configured the filter, it will show up on your post type’s list page. Let’s see how to apply the filter and sort the posts using Advanced Post Types Order.
Directions:
- Navigate to the Post List: Go to the post list for the post type where you’ve added the ACF taxonomy column.
- Apply the Filter: As shown in the uploaded image (“wordpress-posts-dashboard-filter-select.png”), there will be a new filter dropdown for the taxonomy field. In this example, the filter would be Country.
- Select a Term: From the dropdown, select one of the terms from your taxonomy (e.g., “Japan”). This will filter the posts that are assigned to the selected term.
- Drag and Drop Sorting: Once the posts are filtered, Advanced Post Types Order will allow you to rearrange the posts in the filtered list via drag-and-drop. This feature is especially helpful if you want to order posts based on a specific taxonomy term (e.g., order all posts from “Japan” in a custom sequence).
This is particularly useful when you’re managing content that is grouped by specific categories or taxonomies. For example, if you have posts related to different countries, you can easily filter by “Country” and reorder posts related to “Japan” or “France” as needed.
Use Case Example: Sorting Posts by Country
To give you a more concrete example, let’s say you’re managing a travel blog with posts categorized by countries. You’ve created a custom taxonomy called “Country” using ACF and linked it to your posts. In the WordPress admin dashboard, you’ve added a column for “Country” using Admin Columns Pro, and this column now shows up in the post list view.
You can now easily filter all posts related to “Japan” and rearrange them according to how you want them displayed on the front end. This dynamic control over the order of posts helps you manage your content more effectively, particularly when it’s organized by a taxonomy.