0

On a custom post type listing page the registered post statuses are listed as links above the post lists. I've a situation where custom registered post types are showing after 'trash' and I still want trash to be the last listed link.

What can I do? It's hard to find documentation on this because the of the complex terminology. Anyall help appreciated.

enter image description here

0

Turns out you can use this filter to alter the priority of the post_status links:

https://github.com/WordPress/WordPress/blob/5c6b63d3a6874743542d6cede307c98ee370af23/wp-admin/includes/class-wp-list-table.php#L378

$views = apply_filters( "views_{$this->screen->id}", $views );

If your custom post type is 'inbound-email' then the applied filter will look like this:

    add_filter( 'views_edit-inbound-email' , 'function_to_filter_priority' );
    /**
     * rebuild priority of post status links
     * @param ARRAY $links
     * @return ARRAY $new_links
     */
    function function_to_filter_priority( $links ) {
        $new_links['all'] = $links['all'];

        if (isset($links['draft'])) {
            $new_links['draft'] =  $links['draft'];
        }
        if (isset($links['pending'])) {
            $new_links['pending'] =  $links['pending'];
        }
        if (isset($links['sent'])) {
            $new_links['sent'] =  $links['sent'];
        }
        if (isset($links['automated'])) {
            $new_links['automated'] =  $links['automated'];
        }
        if (isset($links['trash'])) {
            $new_links['trash'] =  $links['trash'];
        }

        return $new_links;
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.