Custom Page Templates plugin typifies each request, so customers can easily apply templates for specific request types and developers can easily apply corresponding default template files.

Standard Request Types

  • error_404 - applies when user requests non-existing page. Uses is_404().
  • search - applies when user performs search on a website. Uses is_search().
  • front - applies when user requests frontpage. Uses is_front_page().
  • home - applies when user requests blog home page. Uses is_home().
  • custom_post_type_archive_{post_type} - applies when user requests custom post type archive. Uses is_post_type_archive() and get_post_type().
  • taxonomy_{taxonomy} - applies when users requests taxonomy term page. Uses is_tax(), is_category() and is_tag().
  • post_type_{post_type} - applies when user requests single post type page. Uses is_singular() and get_post_type().
  • date - applies when user requests any date archive. Uses is_date().
  • author - applies when user requests author page. Uses is_author().

Custom Request Types

Custom Page Templates plugin gives you a full freedom customizing request types to match your needs. You can add custom request types and remove or rename existing.

Adding Custom Request Type Options

You can extend the standard list of available request types by writing a filter function for cptemplates/get_rule_options/request hook.

add_filter( 'cptemplates/get_rule_options/request', function( $options ) {
  $options []= array(
    'label' => __( 'Theme specific requests', 'theme-text-domain' ),
    'options' => array(
      array( 'value' => 'some_special_page', 'label' => __( 'Some special page', 'theme-text-domain' ) ),
      array( 'value' => 'another_special_page', 'label' => __( 'Another special page', 'theme-text-domain' ) ),

  return $options;
} );

Identifying Custom Request Type

It is also possible to use custom function for identifying request type. You'll need to add a filter function for the cptemplates/get_current_request_name hook.

add_filter( 'cptemplates/get_current_request_name', function( $request_type ) {
  // Your custom logic for identifying request type
  return $request_type;
} );

Default Templates for Request Types

For each standard or custom request type you can create a default template file. Read this article to learn how to create template files.

Recent Posts