Show only standard posts in admin screen

Question

The situation

In admin screen (edit.php?post_type=post) using format selection dropdown adds a URL parameter like post_format=video.

This makes the query to only look for posts with post-format-video.

There is no option for standard post format in the dropdown because it is removed in the formats_dropdown method of WP_Posts_List_Table class.

Manually changing the URL parameter to post_format=standard doesn’t show any posts at all.

What I’ve tried

  1. Manually changing URL parameter to post_format=standard makes $query->get('post_format') equal post-format-standard. But it doesn’t show any posts at all.

  2. If post_format URL parameter is not present, using pre_get_posts does help — only posts without a format are shown

    function my_pre_get_posts($query) {
        $args = array ( array (
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array(
                'post-format-aside',
                'post-format-audio',
                'post-format-chat',
                'post-format-gallery',
                'post-format-image',
                'post-format-link',
                'post-format-quote',
                'post-format-status',
                'post-format-video'
            ),
            'operator' => 'NOT IN'
        ));
        $query->set( 'tax_query', $args );
    }
    add_action( 'pre_get_posts', 'my_pre_get_posts', 1 );
    

  3. Trying to use pre_get_posts combined with post_format=standard URL param doesn’t make any difference. No posts are shown at all. The tax_query added using pre_get_posts doesn’t seem to override the post_format=standard.

  4. However if the URL param is set to some non-standard format like post_format=standard, tax_query added using pre_get_posts does have effect on results.

The question

How to make post_format=standard URL variable show only the posts without a format (e.g. video or audio) in admin screen (edit.php?post_type=post) — if it’s ever possible to achieve this?

0
, , , Oleg 8 months 0 Answers 99 views 0

Leave an answer