Upstatement / routes

Simple routing for WordPress
188 stars 39 forks source link

typo in description #27

Closed twentyfortysix closed 3 years ago

twentyfortysix commented 3 years ago

Hello,

there is a small typo in description on the end is written

<?php
/* functions.php */

Routes::map('info/:name/page/:pg', function($params){
    //make a custom query based on incoming path and run it...
    $query = 'posts_per_page=3&post_type='.$params['name'].'&paged='.intval($params['pg']);

    //load up a template which will use that query
    $params = array();
    $params['my_title'] = 'This is my custom title';
    Routes::load('archive.php', $params, $query, 200);
});

what you do with "$params = array();" is that you are unnecessarily wiping out the $params value from the function context. In this case we we loose the "$params['pg']" and other data.

jarednova commented 3 years ago

Thanks @twentyfortysix! I just fixed this in https://github.com/Upstatement/routes/commit/28ec4dcaf8dc359945cf5ed4820850d3d9be6ea1