Vaibhav Mav Vaibhav Mav - 1 year ago 141
PHP Question

WordPress add_rewrite_rule 404 error

I am adding rewrite_rules for my custom project.

I was able to make them work till some extent, but have some difficulties.

Here's what i have tried out so far

public function add_query_vars($vars) {
$vars[] = 'gallery';
$vars[] = 'project';
$vars[] = 'palbum';
return $vars;
public function add_endpoint() {

Here project is parent and palbum are all its child.

It seems to work properly at

(These page is to show single album)

But it gives me 404 error at

(These page is to show all albums which the project is parent of)

Any clue why?

Answer Source

Based on your rewrite rule, both the section used for project and palbum are required in order for the rewrite rule to apply. If you modify the rule just slightly, it will match what you are looking for:

public function add_endpoint() {
     * Matches:

Created a test to run against any other iterations you'd like to check -

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download