[Resolved] Use Static Pages as Category Archives

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

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #10428
    Ericka
    Participant

    Hi!
    I follow the instructions in “Use Static Pages as Category Archives” documentation. And everything in good! But im wondering:

    – Do I have to NOINDEX my category pages?
    – Do I have to make a redirection?
    – Is there gonna be duplicate content?

    #10440
    Tom
    Keymaster

    Hi there,

    I believe the code in that article does the redirection for you. The old category pages shouldn’t be accessible if you type them into your address bar.

    However, if you’re worried, it doesn’t hurt to set up a 301 redirect from the old category archives to the new pages. This will make sure all three of those points are dealt with.

    #10446
    Ericka
    Participant

    Ok thanks!!

    #10459
    Tom
    Keymaster

    No problem 🙂

    #10525
    Ericka
    Participant

    Hi! Is me again!

    Is there a way to exclude some categories when the function is active? I dont want all my categories to be static pages, just the “important” ones for SEO purposes.

    #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.

    #10533
    Ericka
    Participant

    You mean here:

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

    But how I adjust the names of the categories? For example, if I have a category with this URL: /category/books/ and a page just: /books/, how i put the name in the code? 😀

    #10540
    Tom
    Keymaster

    If your category name is “Books”, you would do this:

    $targets = array(
        'Books',
    );
    #10543
    Ericka
    Participant

    Ok perfect!! Thanks again 🙂

    #10558
    Tom
    Keymaster

    You’re welcome 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.