Removing base page slug from /ask page

Solved8.12K viewsCore
1

I have installed anspress 2.3-beta2 on an empty wp. Created two pages with the anspress shortcode, one with slug “question”, and one with “home”, i have set home as the wp front page, and question as anspress base.

Now both url.com and url.com/question show the list of questions, and url.com/question/post-name show the question, that works fine. But the ask link (url.com/question/ask), shows a 404 error. If i change the base page slug to “questions” then url.com/questions/ask does open.

But i’d really prefer to have the ask page either on url.com/ask or url.com/question/ask

How could i achieve this?

I tried modifying the includes/rewrite.php file and removing $slug . from line 119 so it would look like:

$new_rules[ "ask/([^/]+)/?"] = "index.php?page_id=".$base_page_id."&ap_page=ask&parent=".$wp_rewrite->preg_index(1);

But the ask link still shows as question(s)/ask, and /ask only shows a 404, I tried saving both anspress options and wp permalinks to rebuild the rewrites but didn’t work.

Is your base page slug as “question” ?

0

Just add this filter, and make sure a page with “ask” slug should not be exist.

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;
}

After adding make sure to save permalink once.

0

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

1

Hello, let’s get it simpl. To create ASK Question in your Menu GO TO WP ADMIN. Go to APPEARANCE_MENU there is Anspress_pages Menu which include ASK, CATEGORIES, USERS,  etc select one by one as your choice then Click ADD TO MENU and Save. Refresh your visitors site url.com. hope it will work