Previews not working for drafts
-
I’ve just inherited a theme built on top of Timber, and I’m fairly unfamiliar with how Timber works. I can’t seem to preview posts that are drafts (published posts can be previewed just fine). The posts are routed to use /news – here’s the code for that:
Not sure why drafts can’t be previewed, does it have anything to do with how the routing is set up? Thank you for helping out and taking a look.
// News Timber::add_route('news/', function($params){ //make a custom query based on incoming path and run it... $query = array( 'posts_per_page' => 6, 'post_type' => array('post'), //array('post','quote'), 'paged' => 0 ); // pass special params $params['page_location'] = 'news'; //load up a template which will use that query Timber::load_template( get_theme_root() . '/gimlet/index.php', $query, 200, $params ); }); // News Pagination Timber::add_route('news/:pg', function($params){ //make a custom query based on incoming path and run it... $query = array( 'posts_per_page' => 6, 'post_type' => array('post','quote'), 'paged' => $params['pg'] ); // pass special params $params['page_location'] = 'news'; //load up a template which will use that query Timber::load_template( get_theme_root() . '/gimlet/index.php', $query, 200, $params ); });
The topic ‘Previews not working for drafts’ is closed to new replies.