- This topic has 15 replies, 2 voices, and was last updated 3 years, 5 months ago by David.
-
AuthorPosts
-
November 6, 2020 at 4:10 am #1520222Nacho
Hello,
How can I redirect 1 category archive page to a custom page or post that has the same slug?
Thanks a lot.
November 6, 2020 at 6:21 am #1520382DavidStaffCustomer SupportHi there,
this article provides a method:
https://docs.wpshowposts.com/article/use-static-pages-as-category-archives/
November 7, 2020 at 3:45 am #1521474NachoHello David,
But that works for all categories, what about for just one category?
Thanks a lot.
November 7, 2020 at 7:33 am #1521791DavidStaffCustomer SupportTry 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.November 8, 2020 at 10:47 am #1522882NachoHello 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.
November 8, 2020 at 11:02 am #1522894NachoHello 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.
November 9, 2020 at 12:26 am #1523323DavidStaffCustomer SupportIs the News archive where the latest posts would normally be displayed ?
November 9, 2020 at 1:16 am #1523383NachoHello 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.
November 9, 2020 at 5:15 am #1523683DavidStaffCustomer SupportHmmm… does the function i provided work correctly if you use a Page ?
November 9, 2020 at 7:45 am #1524066NachoHello David,
Nope, it does not work.
How can I give you more information so you I can help you?
Thanks a lot.
November 9, 2020 at 8:02 am #1524101NachoNovember 9, 2020 at 8:04 am #1524106DavidStaffCustomer SupportI am not sure.
The only alternative would be to use a Redirection plugin or to have a template custom developed for this purpose.November 10, 2020 at 6:38 am #1525230NachoHello David,
I´m quite lost but thanks a lot.
Have a good day man.
November 10, 2020 at 9:45 am #1525715DavidStaffCustomer SupportSorry I couldn’t be of much help. This is a really tricky thing to deal with.
November 11, 2020 at 2:59 am #1526448NachoHello David,
Yeah, super tricky.
Thanks for the help man.
-
AuthorPosts
- You must be logged in to reply to this topic.