How To change Ask page URL

6.94K viewsWordPress
1

Hello,

I installed Anspress on my WordPress site and it works very fine, except that the ask page returns a 404.
The problem is because I set the question page as mysite.com/forum/
And the question slug as “forum” and I need to get links like mysite.com/forum/title-of-the-question

Now when Anspress wants to generate the page mysite.com/forum/ask it gets an error.
It only works if I set the slug as /forum/forum/question-name/
but I can’t do this because I’m moving from another plugin and I should keep the URLS the same as before.

Can you help me?

I have to install it in more then 10 sites.

Hello,
It can be fixed by adding a custom rewrite rule. But I think same slug is cause of issue. try with another slug. and make sure ask page slug is not empty.

Hello Rahul,

Thanks for the attention. The problem is that this websites already have a lot question and answers (they are using and old version of Q&A from WPmudev).
So the question page should be /forum and the slug for the questions /forum too, if we change we lose a lot of our SEO work.
I tried changing the rewrite rules like you in an old post from 2015, but it didn’t work.
How can I change so the ask page is simply /ask, and not /forum/ask?

I sam that we have this on rewrite.php

$new_rules[ $slug . ap_get_page_slug( ‘ask’ ) . ‘/([^/]+)/?’ ] = ‘index.php?page_id=’ . $base_page_id . ‘&ap_page=ask&parent=$matches[#]’;
$new_rules[ $slug . ap_get_page_slug( ‘ask’ ) . ‘/?’ ] = ‘index.php?page_id=’ . $base_page_id . ‘&ap_page=ask’;

But after changing nothing happens, if it is possible to implement a filter on functions.php it would be better so I dont change the plugin.

You gave this solution 2 years ago:
add_filter(‘ap_rewrite_rules’, ‘my_rewrite_rules_for_ap’);
function my_rewrite_rules_for_ap($rules){
$rules[”ask/([^/]+)/?”] = “index.php?page_id=”.$base_page_id.”&ap_page=ask”;
return $rules;
}

But I put it on the functions.php and it didnt work…

If I have several sites, should I get the priority support for each one or just once for all?

0

I have exactly the same error. Please fix it as soon as possible. Thank you.

0

Hello Rahul,

Thanks for the attention. The problem is that this websites already have a lot question and answers (they are using and old version of Q&A from WPmudev).
So the question page should be /forum and the slug for the questions /forum too, if we change we lose a lot of our SEO work.
I tried changing the rewrite rules like you in an old post from 2015, but it didn’t work.
How can I change so the ask page is simply /ask, and not /forum/ask?

I sam that we have this on rewrite.php

$new_rules[ $slug . ap_get_page_slug( ‘ask’ ) . ‘/([^/]+)/?’ ] = ‘index.php?page_id=’ . $base_page_id . ‘&ap_page=ask&parent=$matches[#]’;
$new_rules[ $slug . ap_get_page_slug( ‘ask’ ) . ‘/?’ ] = ‘index.php?page_id=’ . $base_page_id . ‘&ap_page=ask’;

But after changing nothing happens, if it is possible to implement a filter on functions.php it would be better so I dont change the plugin.

You gave this solution 2 years ago:
add_filter(‘ap_rewrite_rules’, ‘my_rewrite_rules_for_ap’);
function my_rewrite_rules_for_ap($rules){
$rules[”ask/([^/]+)/?”] = “index.php?page_id=”.$base_page_id.”&ap_page=ask”;
return $rules;
}

But I put it on the functions.php and it didnt work…

If I have several sites, should I get the priority support for each one or just once for all?

commented on answer

There is a very simplest solution for your problem. Create a page “Ask” with shortcode [anspress page="ask"]. And add a htaccess rule to redirect /forum/ask to /ask page.

I dont know why, when I use the shortcodes of anspress it doesnt work well, I put [anspress page="ask"] in a page, but when I try to send a question it doesn’t work.
With the shortcode [anspress] the first page of questions appear, but if I try to navigate on the other questions pages /questions/page/2 etc… it doesnt work…

Hello Rahul, is it possible to pay just to solve this problem? It is a bit urgent for us

Please get in touch by email [email protected], Thanks

I Tried to contact support by mail and by a form, I get no answer