I'm in the process of creating rather complex sites with Wordpress. I'll have a page template that collects data from other pages and shows them on one page.

These pages are not used anywhere else than in the page template and shouldn't be indexed for search engines or be accessible via a slug.

They are supposed to act as nothing but containers of data.

Is there a way to do this?

  • 1
    How would you want to access such page if not by slug (URL)?
    – Rarst
    Commented Aug 24, 2012 at 12:09

2 Answers 2


Why don't you use is_page(id of the page) check with php and redirect them off that page to the main url?


if (is_page(22)) {
  //php redirect them to the main url
} else {
  //normal template continues


Just to be sure, you can use is_page_template check.

if (is_page_template(templatename.php)) {
  //php redirect them to the main url
} else {
  //normal template continues
  • The whole template has to be extremely versatile, I can't use static numbers. Can one check if it is a page of a certain category? (I use a plugin to add categories to pages)
    – Axel
    Commented Aug 24, 2012 at 11:13
  • I have edited my answer, check for page template instead. Commented Aug 24, 2012 at 11:19

I assume/guess you want to build some sort of HTTP interface to allow people to retrieve data from your service.

WordPress as remote service

This can be done in several ways: Build a template that just spits out JSON-ified or XML-ed data with plain stupid PHP functions like json_decode() or the SimpleXML class.

Another option would be to use WebHooks - there's a plugin for that case: HookPress.

Webhooks are a simple paradigm for developing instant notifications and mashups based on simple HTTP requests. With HookPress you can set up webhooks so that a specified URL (a public service or something you set up) is requested when certain WordPress actions occur. Possible uses include generating push notifications or using non-PHP web technology to extend WordPress.

- HookPress repo description

You can read more about WebHooks on this site. Even with old publishing dates, the posts are still worth reading.

Another option would be the WP HTTP API offered by WP core.

The last option are RSS Feeds, that WP also has built in.

Private mode

WP has "privately" published pages. You can set a password and check for it with post_password_required() - Assuming, that you're using a password on your page (private in submitdiv/publish meta box), you can question for this in your template and force the user to know & enter the password before reaching the content.


The normal hook to redirect is the template_redirect hook. There you can redirect people properly and easily:

function wpse62920_deny_access() 
    global $post;

    // Only for specific post types like 'post', 'page', 'some_custom_post_type'
    if ( ! 'some_post_type' === get_post_type() )

    // Your special file
    include_once( get_stylesheet_directory.'some_template.php' );

    // NEVER! forget to exit - else the default available WP template would jump in.
add_action( 'template_redirect', 'wpse62920_deny_access' );
  • Thanks. But I have a page template, that queries other pages by category and uses the content and featured images to create the page. That's why I'm trying to exclude those pages from the "page" idea. They are supposed to act as nothing but content holders. I hope you get my drift.
    – Axel
    Commented Aug 24, 2012 at 13:09
  • 1
    That's what you've got "posts" or "custom post types" for - not pages. WPs post types are not meant to be "part this, part that". Use one thing (like pages) for one task (like summoning custom post type contents) and other things (like custom post types) for contents. You can add a public => false arg and show_ui => false arg, when registering a custom post type.
    – kaiser
    Commented Aug 24, 2012 at 13:49

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.