Viewing 1 replies (of 1 total)
  • Thread Starter jarad.secco

    (@jaradsecco)

    In case anyone is experiencing the same issue, as a work around I was able to add the following rewrite rule to my theme’s functions.php file to get pagination working for gallery URLs ending in /1/ :

    function gallery_cpt_custom_rewrite_rule() {
            add_rewrite_rule('^galleries/([^/]*)/([^/]*)/?','index.php?gallery=$matches[1]&gal_page=$matches[2]','top');
            flush_rewrite_rules();
    }
    add_action('init', 'gallery_cpt_custom_rewrite_rule', 10, 0);

    The above rewrite rule will stop WP from automatically dropping the trailing /1/ from the URL. Then in the gallery template file, I am able to access the gallery name and page number using $_GET[“gallery”] & $_GET[“gal_page”] params.

Viewing 1 replies (of 1 total)
  • The topic ‘URLs ending in /1/ automatically redirect and strip /1/’ is closed to new replies.