WordPress.org

Ready to get started?Download WordPress

Forums

Register rewrite endpoint and having a static frontpage (3 posts)

  1. paddelboot
    Member
    Posted 1 year ago #

    Hi,

    I am registering a rewrite endpoint which I need to use on a static front page.

    But a link that is as follows:

    http://example.com/myendpoint/myvalue

    will never display the page I have set as frontpage, but will always use index.php.

    Is this a bug, a feature or a misunderstanding?

    Regards,

    Paddelboot

  2. bcworkz
    Member
    Posted 1 year ago #

    A misunderstanding more than likely. Depending on how you added the endpoint, you probably end up with a request like example.com/index.php?myendpoint=myvalue. That's probably enough for index.php to not load your frontpage. index.php tries to decide which template to load based on the arguments, and without hooking some query args filter to manage the provided parameters, it probably fails miserably.

    If you use wp_add_rewrite_rule(), you can add a p parameter passing the ID of your front page to ensure it is loaded and receives the 'myvalue' taken from the initial url.

  3. paddelboot
    Member
    Posted 1 year ago #

    I added it using add_rewrite_endpoint(). According to the Codex, this function also creates the necessary query var(s). Also in other articles, I have not found a statement that endpoints are not supposed to work on static front pages. EP_ALL should include those, as far as I see it. Therefore, I consider it to be more of a bug at the moment.

    The solution with creating a custom rewrite rule just for the front page should work, nevertheless.

    Paddelboot

Topic Closed

This topic has been closed to new replies.

About this Topic