[wp-hackers] Options for Controller - Views

Otto otto at ottodestruct.com
Fri Nov 20 17:22:56 UTC 2009

On Fri, Nov 20, 2009 at 10:55 AM, Mike Schinkel
<mikeschinkel at newclarity.net> wrote:
> To create a generic functionality that lets me add URLs like what follows and have them load appropriate functionality from WordPress such as a post or a list of posts:
> add_custom_url( array(

I don't follow what any of that really means, but I'm pretty certain I
can probably make it simpler for you than using all those hooks.  The
callback one, for example, is relatively easy to do. The rest might be
easy, might not. Depends on what it's doing, I can't tell just from
the names of the bits in your arrays alone.

Email me direct with the code you have and I'll see if I can help you
simplify it.

> The reason I needed to muck with SQL is because, while I could get the URLs to route with just a few hooks, I couldn't get it to select the appropriate posts and/or post lists (I was using More Fields plugin to create unique "content types.")  Yes, it's not exactly a routing issue but without the route being able to access WP functionality to pull the appropriate posts then just having custom URL routes is like having a Bugatti Veyron but no gasoline.

If you can get the variables you need into query vars, then it should
be a straightforward matter to pull the posts you need, and hopefully
to do it without direct SQL modification. However, that's not a
routing issue at all, that's an issue with WP_Query and it being
potentially unable to query your posts in the way you want.

But again, *you don't need to use WP_Query*. A template never has to
mess with the $wp_posts variable if it doesn't want to do so. You can
ignore it entirely and pull the posts you want yourself. Or create a
new WP_Query with special parameters. Or anything you like, once
you're in your template (via a template_redirect), you have total
control over everything. Everything is loaded, all of WordPress is
prepared, but it's the template that waves the baton and displays

> OTOH, if core can be modified so that a route can be specified and tied to a custom post type and/or a custom function all without having to do anything more than specify what I have specified above then that is what we need.

Routing arbitrary URLs to custom functions (via callbacks) is easy
verging on trivial. Custom post type might be, but I need more
information on that.

Sent from Memphis, TN, United States

More information about the wp-hackers mailing list