I am working on a plugin that displays external data, within WordPress.

I am attempting to create two pages. A listing/archive page, and a detail page.


  • /cars/ List all cars
  • /cars/abc/ List the detail for car abc

What I have tried:

I created rewrites that set pagename=mypage. This works pretty well, but when I hook the_content it unfortunately inserts the content inside <article><div class="entry-content">. What I would like though, is for each car in my list, to be its own entry, such as is done on an archive list, with multiple occurrences of <article> that I can control the content of.

I also attempted instead to rewrite as category_name=cars in an attempt to trigger is_archive(), but when I view the page, because there are no posts in this category (for which there wont be), I get a 404 error and/or Nothing Found.

How can I override this to supply my own data (non-posts). I would like to do this using the_content or something similar, that doesn't require a custom template. Hopefully getting WordPress to loop through the data, but I would be happy if I can just write out the <article> entries myself.

  • are you trying to make this work with any theme? semantically, you can put a single section inside an article, then each car would be an article in that section. the issue with trying to create posts (that aren't really posts) that can be iterated over within the loop is that you have to consider all of the possible template tags that could be called on those post objects. it would be a lot of work to do that error-free. I would inject it within a filter on the page's content and not try to get too tricky. – Milo Feb 21 '15 at 1:21
  • Yes, I would like it to work with any theme. – Brad Feb 21 '15 at 2:27
  • I don't see how you'd do it without just inserting it into a page's content via the_content filter. You'd have no way of knowing what the markup of a page template will be and if it could even deal with multiple iterations of the markup contained within the loop. – Milo Feb 21 '15 at 2:47
  • Milo, thanks. You've made me rethink it, and i believe the most sensible solution is what I already have (using a single page). It will require the least number of workarounds and be more compatible long term. Unfortunately I can't mark your comment as the answer. – Brad Feb 21 '15 at 16:49
  • @Milo Can you post your comment as an answer? – Brad Mar 3 '15 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.