How to add custom term in wordpress post slug?

I want to build an URL in WordPress site with a pattern which looks like this:[category-name]/[slug]/[photo-{0-9}]/

Tried re-writing URLs and added "photo" param to query var to catch the photo number, but couldn't succeed. Am already using a plugin to remove /category/ from URLs.

Any idea to achieve it?

Thanks in advance!


You can use it like this

it is not clear that what are [slug] and {0-9} are. But I think you can manage with them with this answer

Was able to get this working Adding the solution here so someone can make use or tune it further

I did this adding following rewrite key value pair to $wp_rewrite->rules array:

'([^)]+)/([^)]+)/(photo-\d+)?$' => 'index.php?category_name=$matches[1]&name=$matches[2]&photo=$matches[3]'

This regex groups (inside parenthesis()) url to $matches array which is turn assigned to WP query string.

Need Your Help

onKeyListener not working as i want it to... in android

android listview android-listview

Currently I am using the following code to set onKeyListener for editText in android.