updates - Is the root index.php file part of the Core?

admin2025-06-02  1

The contents of the /index.php is as follows:

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

If I make any changes in this file, then do a Wordpress Update, will the contents of this file be replaced? I've not been able to find any references online for this file, only Wordpress' /wp-includes and /wp-admin folders.

I don't have access to the php.ini file and want to change the session cookie lifetime setting by adding the following code:

    $seconds = 31557600; //1 year
    ini_set('session.gc_maxlifetime', $seconds);
    ini_set('session.cookie_lifetime', $seconds);

but don't want to add it to a file that potentially could be overridden in a couple of months time.

The contents of the /index.php is as follows:

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

If I make any changes in this file, then do a Wordpress Update, will the contents of this file be replaced? I've not been able to find any references online for this file, only Wordpress' /wp-includes and /wp-admin folders.

I don't have access to the php.ini file and want to change the session cookie lifetime setting by adding the following code:

    $seconds = 31557600; //1 year
    ini_set('session.gc_maxlifetime', $seconds);
    ini_set('session.cookie_lifetime', $seconds);

but don't want to add it to a file that potentially could be overridden in a couple of months time.

Share Improve this question asked Mar 18, 2019 at 16:44 Richard Parnaby-KingRichard Parnaby-King 1158 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 4

Yes, index.php is part of core and is liable to be overwritten.

In fact, if you look at the process to manually update WordPress, step 7 is:

Upload all new loose files from the root directory of the new version to your existing WordPress root directory

That may include index.php.

You can put custom PHP code in a custom plugin or theme. If using a pre-built theme, first create a child theme and then put your code in that child theme's functions.php.

If you run PHP as Apache module you can set php.ini values in .htaccess:

AllowOverride Options
php_value session.gc_maxlifetime 31557600
php_value session.cookie_lifetime 31557600
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748795225a313781.html

最新回复(0)