Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_reset_front_page_settings_for_post() WordPress Function

This function resets the front page settings for a given post. This is useful for when you want to change the front page settings for a post, but don't want to lose the settings for other posts.

_reset_front_page_settings_for_post( int $post_id ) #

Reset the page_on_front, show_on_front, and page_for_post settings when a linked page is deleted or trashed.


Description

Also ensures the post is no longer sticky.


Top ↑

Parameters

$post_id

(int)(Required)Post ID.


Top ↑

Source

File: wp-includes/post.php

function _reset_front_page_settings_for_post( $post_id ) {
	$post = get_post( $post_id );

	if ( 'page' === $post->post_type ) {
		/*
		 * If the page is defined in option page_on_front or post_for_posts,
		 * adjust the corresponding options.
		 */
		if ( get_option( 'page_on_front' ) == $post->ID ) {
			update_option( 'show_on_front', 'posts' );
			update_option( 'page_on_front', 0 );
		}
		if ( get_option( 'page_for_posts' ) == $post->ID ) {
			update_option( 'page_for_posts', 0 );
		}
	}

	unstick_post( $post->ID );
}


Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More