php - Adding a rewrite rule to wordpress using regex


I'm trying to write a rewrute rule for wordpress:

add_rewrite_rule( '(.*)/([0-9]+)/?$', 'index.php?name=$matches[1]&p=$matches[2]','top' ); // check for not page in matches[1]

I want to add two more conditions in$matches[1] i.e.(.*) should not contain any/ and also should not contain the stringpage.

To sum up, I want to match only strings like:


But not these:


People are also looking for solutions to the problem: php - Object of class charts could not be converted to string


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.