WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 18 months ago

#14551 reopened defect (bug)

menu item : current_page_parent : issue with Front page displays

Reported by: hughestm@… Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch needs-testing
Focuses: Cc:

Description

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 5 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 @hughestm@…5 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.

comment:2 @hughestm@…5 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;}

@wojtek.szkutnik5 years ago

comment:3 @wojtek.szkutnik5 years ago

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

comment:4 @c3mdigital2 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.

comment:5 @helen2 years ago

  • Milestone Awaiting Review deleted

comment:6 @hughestm@…2 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.

comment:7 @hughestm@…2 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:8 @hughestm@…2 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.

comment:9 @dd322 years ago

  • Keywords close removed
  • Milestone set to Awaiting Review

comment:10 @SergeyBiryukov2 years ago

  • Keywords has-patch needs-testing added
Note: See TracTickets for help on using tickets.