How To change Ask page URL
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 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?
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.