WordPress.org

Ready to get started?Download WordPress

Forums

URL parameters generate 404 error (5 posts)

  1. pixelgeek
    Member
    Posted 4 years ago #

    I am trying to create a custom page template that takes in URL data similar to the way the archives in WP work

    So I want to use:
    http://localhost/blog/posts-by-site/site/14/

    where posts-by-site is the template.

    For some reason the URL
    http://localhost/blog/posts-by-site/14/

    works but this URL
    http://localhost/blog/posts-by-site/site/14/

    or this URL
    http://localhost/blog/posts-by-site/14/page/2/

    both generate a 404 error.

    Is there a simpler way to do this other than a custom page template?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    You can't use the name of a custom template in your permalinks.

    http://codex.wordpress.org/Using_Permalinks

  3. pixelgeek
    Member
    Posted 4 years ago #

    Its not a permalink

    And it does work, just not in some instances. So I am trying to figure out why it doesn't work in them.

    If this isn't the way to do this then a pointer to the correct method would be helpful

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Its not a permalink

    But WordPress is going to try and treat it as a permalink - which could lead to problems.

    Have you tried examining the query_var in that template to see if there's anything you can grab with regard to the referring URL? Or simply using $_SERVER['QUERY_STRING']?

  5. pixelgeek
    Member
    Posted 4 years ago #

    But WordPress is going to try and treat it as a permalink

    Well yes and no. You shouldn't confuse the Permalinks concept in WP and that actualization of it via rewrite rules. People have been using that sort of URL structure for years before WP used it as its permalinks

    You're right that this is going to cause an issue because there are a number of rewrite rules in WP. And that appears to be the solution.

    I've added a rewrite fliter and it works and I now just need to add support for paging.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.