Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Last active March 7, 2024 18:09
Show Gist options
  • Save szepeviktor/1682e9dee9bd36c8367590020baaa0e9 to your computer and use it in GitHub Desktop.
Save szepeviktor/1682e9dee9bd36c8367590020baaa0e9 to your computer and use it in GitHub Desktop.
Installing WordPress core in a subdirectory
<?php
/** Tell WordPress to load the WordPress theme and output it. */
define('WP_USE_THEMES', true);
/** Load the WordPress Environment and Template. */
require __DIR__ . '/project/wp-blog-header.php';
<?php
// "wp-content" location.
define('WP_CONTENT_DIR', __DIR__ . '/wp-content');
define('WP_CONTENT_URL', 'https://example.com/wp-content');
@szepeviktor
Copy link
Author

szepeviktor commented Mar 7, 2024

/index.php
/wp-config.php
/wp-content/
/project/ 👈🏻 WordPress core, change this name to a non-generic word, e.g. the project slug
wp option update home "https://example.com"
wp option update siteurl "https://example.com/project"

Login URL: https://example.com/project/wp-admin/

@szepeviktor
Copy link
Author

// Don't redirect automatically to admin
remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);

https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment