[wp-hackers] Map a custom url to its content.

Otto otto at ottodestruct.com
Wed May 19 14:02:32 UTC 2010


If you want to use an existing template from the current theme, then
there's a few ways to do it.

If you just want the look, then simply calling get_header and
get_footer and get_sidebar and such will generally do the trick.
Basically, at this point in the code, you are the template. You can
act just like one.

If you want to get a specific template, then you could do something like this:
$template = get_single_template();
include($template);

But the problem with that is that you don't control what the template
is going to output. For that, to adjust the content and such, you'd
have to modify the query, and that's a whole different kettle of fish.

It would help for you to be more specific and explain what exactly
you're trying to do.

-Otto



On Wed, May 19, 2010 at 12:21 AM, Rajasekharan S <rajasekharan.s at tcs.com> wrote:
> This was otto's suggestion:
>
> add_action('template_redirect','your_function');
> function your_function() {
>  if ($_SERVER['REQUEST_URI'] == 'whatever-you-want-the-uri-to-be') {
>    // produce your output
>  exit();
>  }
> }
>
> This is almost what I want it to be. A detail that I forgot to mention in
> the first post was that the mapped URL should use  the template that is
> currently active. The content that the plugin generates should go in the
> content area.
>
> Any ideas how I can map the URL to a function and have it use the
> currently active template?
>
> Thank you all for your responses.
>
> Raj
>
>
>
>
> From:
> Otto <otto at ottodestruct.com>
> To:
> wp-hackers at lists.automattic.com
> Date:
> 05/18/2010 10:43 PM
> Subject:
> Re: [wp-hackers] Map a custom url to its content.
> Sent by:
> wp-hackers-bounces at lists.automattic.com
>
>
>
> On Tue, May 18, 2010 at 6:58 AM, Rajasekharan S <rajasekharan.s at tcs.com>
> wrote:
>> Hi all,
>>
>> Here's what I want my plugin to do:
>>
>> I want my plugin to map a URL on the blog to some content that it will
>> generate like a form. The plugin generates the URL. For example:
>>
>> http://www.myblog.com/my-app-reserves-this-url-automatically/
>>
>> Visitng the URL generates shows a form. This web page is not a "page" of
>> any content type that was created using the wordpress admin panel.
>> Generating this page should not require the user to create a page or
> post
>> manually using the admin panel.
>>
>> So my question is :
>>
>> How can I map a URL to a function that will return some content that the
>> user will see at that URL?
>
> add_action('template_redirect','your_function');
> function your_function() {
>  if ($_SERVER['REQUEST_URI'] == 'whatever-you-want-the-uri-to-be') {
>    // produce your output
>  exit();
>  }
> }
>
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list