[Support request] Redirect category to a page

Home Forums Support Redirect category to a page

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1520222
    Nacho

    Hello,

    How can I redirect 1 category archive page to a custom page or post that has the same slug?

    Thanks a lot.

    #1520382
    David
    Staff
    Customer Support
    #1521474
    Nacho

    Hello David,

    But that works for all categories, what about for just one category?

    Thanks a lot.

    #1521791
    David
    Staff
    Customer Support

    Try changing this line:

    if ( is_admin() ) {

    to

    if ( is_admin() && !is_category( 'category-slug' ) ) {

    Change the category-slug to the slug of the Category you want to redirect.

    #1522882
    Nacho

    Hello David,

    I´ve tried that but it redirects to 404 page.

    Here is the code:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() && !is_category( 'noticias' ) ) { 
            return $query_vars;
        }
    
        if ( isset( $query_vars['category_name'] ) ) {
            $pagename = $query_vars['category_name'];
    
            $query_vars = array( 'pagename' => "$pagename" );
        }
    
        return $query_vars;
    } );

    How can I solve this?

    Thanks a lot.

    Bests.

    #1522894
    Nacho

    Hello again David,

    Is it a problem that the page we´re trying to refer is a post and not a page?

    Maybe I should´ve explained better. So what I want is 1 category page redirect to a page and the others to the category archive page.

    And also I actually want to send particular category page to a custom page and subcategories to the category archive page if this helps.

    So for example, mydomain.com/news go to the news custom page and mydomain.com/news/economy go to the category archive page.

    Thanks a lot.

    #1523323
    David
    Staff
    Customer Support

    Is the News archive where the latest posts would normally be displayed ?

    #1523383
    Nacho

    Hello David,

    Nope, News archive is not where the latest posts would normally be displayed. For that I´ve a blog category.

    Let me explain, I´ve this categorization:

    – Category News: Subcategory Economy, Subcategory Society.
    – Category Freelancers: Subcategory Taxes, Subcategory Social security.

    So for News and Freelancers which are categories I want to create a more complex page than the one WordPress gives you for categories. That´s why I want to redirect those category archive pages to a custom page which is actually a post.

    Hope it makes sense.

    Thanks a lot David.

    #1523683
    David
    Staff
    Customer Support

    Hmmm… does the function i provided work correctly if you use a Page ?

    #1524066
    Nacho

    Hello David,

    Nope, it does not work.

    How can I give you more information so you I can help you?

    Thanks a lot.

    #1524101
    Nacho

    Hello David,

    Could the Yoast plugin interfere here with this configuration?

    https://d.pr/i/2bCh3W

    #1524106
    David
    Staff
    Customer Support

    I am not sure.
    The only alternative would be to use a Redirection plugin or to have a template custom developed for this purpose.

    #1525230
    Nacho

    Hello David,

    I´m quite lost but thanks a lot.

    Have a good day man.

    #1525715
    David
    Staff
    Customer Support

    Sorry I couldn’t be of much help. This is a really tricky thing to deal with.

    #1526448
    Nacho

    Hello David,

    Yeah, super tricky.

    Thanks for the help man.

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