Use Static Pages as Category Archives

In some cases, you may want to replace your category archives with a static page so you can use WP Show Posts as your archives.

To do this, you need to add this function to your site.

add_filter('request', function( array $query_vars ) {
    if ( is_admin() ) {
        return $query_vars;

    if ( isset( $query_vars['category_name'] ) ) {
        $pagename = $query_vars['category_name'];

        $query_vars = array( 'pagename' => "$pagename" );

    return $query_vars;
} );

Adding PHP

Now, you need to create static pages for each category you have, and the slugs must match.

For example, let’s say we have a category named Best Vacations, with a slug of best-vacations. It would look something like

Now you need to create a new static page with that matching slug:

You can now add your Show Posts shortcode on that page, and WordPress will use the content of this static page when a category archive is reached.