Make WordPress Core

Opened 14 years ago

Last modified 5 years ago

#14551 reopened defect (bug)

menu item : current_page_parent : issue with Front page displays

Reported by: hughestmwfuedu's profile hughestm@… Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:


Settings > Reading > Front page displays: set to your latest posts
Settings > Reading > Posts page: set to anything

When the menus are building, they are only checking that something was set by the dropdown for posts page, even though the parent setting says the posts are to be on the home page. The pages on the site have the correct logic, however the menu adds "current_page_parent" to the item selected in the "Posts page" menu, even though it's not really the parent.

The work around is to just remember if you switch from having posts on a different page back to having them on the front, you need to set the "Posts page" back to "select" and everything works correctly, but getting users in my multi-site install to do that might be asking a bit much.

Attachments (1)

14551.diff (692 bytes) - added by wojtek.szkutnik 14 years ago.

Download all attachments as: .zip

Change History (13)

#1 @hughestm@…
14 years ago

Possible solution:
File: wp-includes/nav-menu-template.php

Add after line 260:
$front_page_displays = (int) get_option( 'show_on_front' );
if($front_page_display == 'posts'){$home_page_id=0;}

This checks to make sure the first toggle is set to have page or posts on the front. If posts, then reset $home_page_id (page_for_posts) to 0 (value when drop down is set to "select").

I know there are possibly a few other locations you could add similar logic. I'm not sure what else the $home_page_id (page_for_posts) value would be used for.

#2 @hughestm@…
14 years ago

Change to the two lines: need to remove (int) from get_option.

$front_page_displays = get_option( 'show_on_front' );
if($front_page_display == 'posts'){$home_page_id=0;}

#3 @wojtek.szkutnik
14 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch needs-testing gsoc added; current_page_parent menu posts on page removed

#4 @c3mdigital
11 years ago

  • Keywords close added; has-patch needs-testing gsoc removed
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 3.0.1 to 3.0

Invalid. When front page is set to latest posts, you are not able to select the page for posts option.

#5 @helen
11 years ago

  • Milestone Awaiting Review deleted

#6 @hughestm@…
11 years ago

Hey guys, either my original post wasn't clear, or it's not being read properly. I understand that the first time you come to the page (Settings > Reading) the option "Front page displays" is set to "Your latest posts" and everything is grayed out. That's all well and good.

BUT, if a user switches to use a static page for their front page, and moves the posts to another page on their site, AND then goes back to displaying latest posts on the homepage (without resetting "front page" and "posts page" settings back to "select") , the programming logic of the menus doesn't work properly.

#7 @hughestm@…
11 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

#8 @hughestm@…
11 years ago

As an additional point of clarification, while I realize that when someone puts the setting back to front page display latest posts, that visually the other settings are disabled, the database still retains the fact that you've previously selected another location for posts and for the front page that the menu logic is considering, even though it shouldn't.

#9 @dd32
11 years ago

  • Keywords close removed
  • Milestone set to Awaiting Review

#10 @SergeyBiryukov
11 years ago

  • Keywords has-patch needs-testing added

#11 @chriscct7
9 years ago

  • Keywords needs-refresh added

#12 @christophherr
8 years ago

  • Keywords needs-testing needs-refresh removed

The settings under "A Static Page" are now automatically reset when "Your latest posts" is selected and the changes are saved.
The class current_page_parent is no longer added to the previous posts page.

Note: See TracTickets for help on using tickets.