I have a custom post type, lets say ‘work’.
There are some categories under work, ‘taskA’ and ‘taskB’
There are some posts {post1, post2, post3} in category taskA and some posts {post4,post5,post6} in category taskB.
I want to list all posts @ mydomain.com/work
So i created a page with title work.
And listed all posts.
All posts under ‘work’ should have the url as mydomain.com/work/post1
…
So while registering the custom post type, i used the rewrite slug as ‘work’.
Everything was working fine until i wanted pagenation to work.
On accessing url, mydomain.com/work/page/1
, error 404 is thrown.
On changing the rewrite slug as ‘works’, error 404 is resolved.
What approach should I follow to maintain the desired url structure?
Also I want to list all posts under ‘taskA’ @ mydomain.com/work/taskA
Using rewrite slug as ‘work’ didnot help. On using rewrite slug as ‘work-task’, everything seems working fine.
But the url looks like mydomain.com/work-task/taskA
Any Suggestions for change in approach?
Found a solution!
Deleted the page work.
And instead of displaying all posts from custom page template,displayed it from archive.php.
Pagenation will start working at this step.
For Taxonomy, i changed the slug to ‘work’, and added following code in functions.php.
Url Structure maintained and pagenation works as well!