Make WordPress Core

Opened 6 years ago

Last modified 8 weeks ago

#23867 reopened defect (bug)

add_rewrite_endpoint causes front-page.php template to be ignored

Reported by: lumpysimon Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.1
Component: Rewrite Rules Keywords: reporter-feedback, bulk-reopened
Focuses: Cc:


I have a front-page.php template in my theme folder, as per the template hierarchy this is used regardless of whether I am showing posts or a page as the front page.

However, when I add a rewrite endpoint (on the init hook), index.php is used for the front page template when I add my query var to the URL. It makes no difference if I set the front page to show posts or a page. If I do not add the query var, front-page.php is correctly used.

i.e. http://domain.com correctly uses front-page.php, http://domain.com/nl wrongly uses index.php

This happens whether I use EP_ALL or EP_ROOT as the places parameter.

All other template files are fine, it's only the homepage with the problem as far as I can see.

Change History (12)

#1 @toscho
6 years ago

  • Cc info@… added

#2 @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback added

Could you provide a piece of code to reproduce the issue?

#3 @lumpysimon
6 years ago

  • Keywords reporter-feedback removed
add_action( 'init', 'my_add_rewrite_endpoint' );

function my_add_rewrite_endpoint() {
	add_rewrite_endpoint( 'nl', EP_ALL );

that's pretty much it. if there's a front-page.php template in the theme folder it then gets ignored when visiting http://domain.com/nl.

#4 @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback added

Could not reproduce. My steps:

  1. Added your code to theme's functions.php.
  2. Flushed rewrite rules by visiting Permalink Settings screen.
  3. http://trunk.wordpress/ and http://trunk.wordpress/nl/ are displayed using front-page.php.
  • Have you flushed rewrite rules after adding the code?
  • What is you permalink structure?

#5 @justnorris
5 years ago

  • Cc justnorris added
  • Severity changed from normal to major
  1. Add the code to theme's functions.php
add_action( 'init', 'my_add_rewrite_endpoint' );

function my_add_rewrite_endpoint() {
	add_rewrite_endpoint( 'nl', EP_ALL );
  1. Flush rewrite rules
  2. Create a page called "My front page" and add content "Testing Things and Stuff"
  3. Go to "Settings -> Reading", set "Front page displays: -> A static page: "My front page"
  4. Open http://trunk.wordpress/ -> expected: "Testing Things and Stuff".
  5. Open http://trunk.wordpress/nl -> expected: "Testing Things and Stuff", failed, 404 loaded instead.

Does that count as the same bug or should I create a separate ticket ?

On top of that:

  1. Add Function, Flush Rules:

index.php generates regular index.php ( and not "My front page" Page )

  1. Remove Function, DO NOT FLUSH RULES:

index.php generates "My front page" page (unexpected), but doesn't utilize the "nl" query_var ( expected, because there is no function that would register "nl" query var

  1. Flush Rewrite rules, 404 page is generated (expected)

Wordpress 3.7.1

Last edited 5 years ago by justnorris (previous) (diff)

#6 @fabrizim
5 years ago

I think the issue occurs during the parse_vars in WP_Query. See the code here:


This test does not take into account custom endpoints, only a hardcoded set of query args - any additional args result in a failing test. I think this should be expanded to include any user defined endpoints. I wrote a plugin for using a custom post type as the front page and during some development, added a filter to fix this, now endpoints can be used on a static front page. See the following for the specific function that I wrote. It would only be 2 lines of code to add to the core, but I don't know how to add a "pull request" in svn :/


#7 @paddelboot
5 years ago

Any news when this will be fixed?

#9 @swissspidy
3 years ago

#31438 was marked as a duplicate.

#11 @iseulde
4 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This ticket has not seen any activity in over *two* years, so I'm closing it as "wontfix".

The ticket may lack decisiveness, may have become irrelevant, or may not have gathered enough interest.

If you think this ticket does deserve some attention again, feel free to reopen.

For bugs, it would be great if you could provide updated steps to reproduce against the latest version of WordPress (5.0.2 at the time of writing). Remember images or a video can be superior to explain a problem. At the very least, quickly test again to make sure the bug still exists.

If it’s an enhancement or feature, some extra motivation may help.

Thank you for your contributions to WordPress! <3

#12 @JeffPaul
8 weeks ago

  • Keywords bulk-reopened added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

A decision was made to reopen tickets that were closed in the bulk edit that this ticket was affected by. This ticket is being placed back into the Awaiting Review milestone so it can be individually evaluated and verified to determine if it is still relevant/valid or reproducible.

Note: See TracTickets for help on using tickets.