Upstatement / routes

Simple routing for WordPress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Route with RSS Feed

sidonaldson opened this issue · comments

Hi guys, I've been trying to get a custom route for a custom archive page to work with a RSS feed.

The page itself works great with pagination etc. Only the feed doesn't exist.

Here is some sample code:

    // create CPT (x 3)
    register_post_type($name, array(
      'label' => 'custom1',
      'public' => true,
      'capability_type' => 'page',
      'supports' => array( 'title', 'author', 'excerpt', 'revisions', 'thumbnail'),
      'taxonomies' => array('post_tag'),
      'has_archive' => true
    ));

    // CPT route
    Routes::map('test/filter/:filter', function($params){
        $query = array(
          'post_type' => array('custom1', 'custom2', 'custom3' )
        );
        $filter = $params;
        Routes::load('archive.php', $filter, $query, 200);
    });

    // paging CPT route
    Routes::map('test/filter/:filter/page/:page', function($params){
        $query = array(
          'post_type' => array('custom1', 'custom2', 'custom3' ),
          'paged' => intval($params['page'])
        );
        $filter = $params;
        Routes::load('archive.php', $filter, $query, 200);
     });

I'm wondering if I need to create the feed itself as I'm not sure the Route method does it. {url}/feed is not found.

I've also tried creating a new WP_query but that only creates an error on line 140 of Routes.php

// CPT route
    Routes::map('test/filter/:filter', function($params){
        $query = array(
          'post_type' => array('custom1', 'custom2', 'custom3' )
        );
        $filter = $params;
        Routes::load('archive.php', $filter, $query, 200);
    });

Any help is much appreciated. (Also I think the readme might be out dated)