How can the admin area default to showing only published posts?

How can the admin area default to showing only published posts?

How can the admin area default to showing only published posts?

You’ve come to the correct spot if you’re seeking for a solution to have the admin area default to only showing published posts.

WordPress currently by default shows all pages/posts in the admin area’s list, whether they have been published or not.

WP admin all post

Let’s imagine you have a lot of drafts but are normally more interested in changing the published pages/posts, so all it takes to view them is another click and a complete reload.

Is there a way to make WordPress defaultly display only published posts and pages?

Most likely, the global variable $submenu will be sufficient.

Simply insert this code into your functions.php file to display published articles by default on post links. The full list of published posts can then be viewed by going to the “All” page.

Also Read: How to Fix the Custom Menu Items Limit in WordPress

By default, should Custom Post Type only show published posts?

add_action( 'admin_menu', 'icw_default_published_custom_post_type' );
 
function icw_default_published_custom_post_type() 
{
    global $submenu; 
   // OTHER POST TYPES
    $cpt = array( 'portfolio','recipe' ); // <--- custom post type foreach( $cpt as $pt ) { foreach( $submenu[ 'edit.php?post_type=' . $pt ] as $key => $value )
        {
            if( in_array( 'edit.php?post_type=' . $pt, $value ) )
            {
                $submenu[ 'edit.php?post_type='.$pt ][ $key ][2] = 'edit.php?post_status=publish&post_type='.$pt;
            }
        }   
    }
}

Now select Posts -> All Posts from the admin menu on the left. You’ll automatically receive a list of published posts.

WP all post

Default Setting in WooCommerce Admin Panel: Show List of Published Products

With user-friendly additions like a search box and filters, your all goods table can include any product information you desire. This code update makes Published posts the default display. For WooCommerce Products, you want the same thing to occur.

// to only display published products, update the WooCommerce Products link.

function icw_woo_change_admin_products_link() {

    global $submenu;

    $submenu['edit.php?post_type=product'][5][2] = 'edit.php?post_status=publish&post_type=product';

}

add_action( 'admin_menu', 'icw_woo_change_admin_products_link' );

Wrapping up

At InCreativeWeb, our proficiency in WordPress web creation distinguishes us as the premier agency to work with when developing your website. Our blog post on “How can the admin area default to showing only published posts” is only a small sample of our WordPress expertise.

When you choose InCreativeWeb for your project, you’re opting for a team of experienced WordPress web developers. We specialize in creating custom, user-friendly WordPress websites that meet your specific demands and objectives. Your project is in capable hands thanks to our commitment to quality, careful attention to detail, and client satisfaction.

InCreativeWeb is your go-to partner if you need experienced WordPress web developers to make your online vision a reality. Get in touch with us right away, and together we’ll create a beautiful WordPress website that achieves your goals.

We hope this article helped you learn the complete steps for defaulting to only displaying published posts. According to your needs, the functionality can be expanded. Hope that this guide will be beneficial to you. Keep reading keep exploring.

About Author:

Jayesh Patel is a Professional Web Developer & Designer and the Founder of InCreativeWeb. As a highly Creative Web/Graphic/UI Designer – Front End/PHP/WordPress Developer, with 14+ years of experience, he also provide complete solution from SEO to Digital Marketing. The passion he has for his work, his dedication, and ability to make quick, decisive decisions set him apart from the rest.


Jayesh Patel
Author
Jayesh Patel

Jayesh Patel is a Professional Web Developer & Designer and the Founder of InCreativeWeb.

As a highly Creative Web/Graphic/UI Designer - Front End / PHP / WordPress / Shopify Developer, with 14+ years of experience, he also provide complete solution from SEO to Digital Marketing. The passion he has for his work, his dedication, and ability to make quick, decisive decisions set him apart from the rest.

His first priority is to create a website with Complete SEO + Speed Up + WordPress Security Code of standards.



Explore

Related Articles

16th December, 2024

The WordPress Admin Dashboard: What is it and its Importance

27th November, 2024

How AI-generated Content and Plagiarism Can Be Identified?

25th November, 2024

The Advantages of Using Independent UX Designers for Your Project