On my wordpress site (I am using this as a CMS) i have the following structure for a post:
http://www.domain.com/news/categorytitle/54/title-of-post/. I can get to the post without problems and I can get to the http://www.domain.com/news/ without problems.
How dit I do this:
I have created a few pages with custom query's in them to display all the posts that have a corresponding custom field. Example:
- news.php pagetemplate with in it a custom query that only displays posts where the custom field "news" is checked.
- Page named "news" which uses the news.php as a page template. This page has a permalink: http://www.domain.com/news/ which works great.
The problem is that I cannot get the url http://www.domain.com/news/categorytitle/ to work properly so I can list all news items in that specific category.
The url works but the page is displaying ALL the posts in the specific category and not just the posts within that category that also have the "news" field checked.
I have tried to use the code below in my functions.php file but it does not seem to work.
I hope someone can point me in the right direction?
$new_rules = array(
'news/(.+?)/' => 'index.php?pagename=news&category_name='.$wp_rewrite->preg_index(1)
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
Adding rewrite rules