We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Use Static Pages as Category Archives Reply To: Use Static Pages as Category Archives

#10527
Tom
Keymaster

Try this:

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

    $targets = array(
        'My name here',
        'Another',
        'One More Name',
    );

    if ( isset( $query_vars['category_name'] ) && in_array( $query_vars['category_name'], $targets ) ) {
        $pagename = $query_vars['category_name'];

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

    return $query_vars;
} );

Then adjust the names of the categories you want to target in the $targets array.