0

It seems like this question has been asked not infrequently, but I still can't make heads of it. I followed the Rewrite API Guide to look at how to merge, but I want something like this:

Category = categories, built in. Food = custom taxonomy.

When I enter http://mysite.com/food/category to find all posts in that category and that foot type, similar to

http://mysite.com/index.php?category=category&food=food

I'll also have pages, which aren't attached to a "food" or category, and the permalink fails if i simply put %foood%/%category%/ into the permalink settings.

Does anyone have any recommendations?

4
  • how will WordPress distinguish between food/category and parent-page/child-page? rewrite rules need uniqueness or they'll conflict with each other.
    – Milo
    Commented May 1, 2014 at 19:46
  • OK, I'd love help attacking this point then. Commented May 1, 2014 at 20:17
  • Did you solve your problem @dama_do_bling ? If yes, there are some friends waiting for answer :)
    – Eray
    Commented Mar 31, 2015 at 4:02
  • 1
    @Eray see my answer below. Commented Mar 31, 2015 at 12:45

1 Answer 1

1

What I ended up doing was setting up an endpoint for food, like so:

global $wp_rewrite;
$wp_rewrite->add_endpoint( 'food', EP_PERMALINK | EP_PAGES );
$wp_rewrite->flush_rules();

function printview_query_vars($vars)
{ array_push($vars, 'food');
  return $vars;
}
add_filter('query_vars','printview_query_vars');

Then I'd get a url like http://mysite/pagename/food/fruits/shelves/ and the wp_query would contain something like food=>fruits/shelves, which then i can parse myself into a custom query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.