Make WordPress Core

Opened 9 years ago

Last modified 3 years ago

#23867 new defect (bug)

add_rewrite_endpoint causes front-page.php template to be ignored

Reported by: lumpysimon Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: Rewrite Rules Keywords: reporter-feedback
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. correctly uses front-page.php, 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 (10)

#1 @toscho
9 years ago

  • Cc info@… added

#2 @SergeyBiryukov
9 years ago

  • Keywords reporter-feedback added

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

#3 @lumpysimon
9 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

#4 @SergeyBiryukov
9 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
8 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 8 years ago by justnorris (previous) (diff)

#6 @fabrizim
8 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
8 years ago

Any news when this will be fixed?

#9 @swissspidy
6 years ago

#31438 was marked as a duplicate.

Note: See TracTickets for help on using tickets.