How can I have nginx serve WordPress at /blog?

Here’s what mostly works: Have an nginx config file for the subdomain setup, and ensure that http://wordpress.example.com works. In the nginx default config, have a location block for /blog that proxies to the subdomain: location /blog { rewrite ^/blog(/?.*)$ $1 break; # remove “/blog” proxy_set_header Host wordpress.example.com; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://wordpress.example.com; } In wp-config.php, … Read more

get_query_var not working for subdirectory

You shouldn’t use get_query_var for getting the pagename (slug) – there is no guarantee that pagename will be set, depending on your permalink structure (or lack thereof). Instead, check if the request is for a page, and then get the slug directly from the queried object: if ( is_page() ) { $slug = get_queried_object()->post_name; }

Theme in wp-content but my index.php search theme files in root

I assume you are adding your stylesheets like this in your header: <link rel=”stylesheet” type=”text/css” href=”https://wordpress.stackexchange.com/questions/285785/css/style.css”> Which won’t work. To construct the path dynamically, you need to use the PHP functions offered for this. Make sure your header has <?php wp_head(); ?> in it, and then enqueue your style in your theme’s functions.php file as … Read more

Change directory of javascript files

go to your themes functions.php and find line 122. You will find navigation.js function. get_template_directory_uri() . ‘/js/navigation.js and change it to get_template_directory_uri() . ‘assets/js/navigation.js do it again for skip-link-focus-fix.js code located on line 124. For customizer go and find customizer.php in ‘inc’ folder. Go line 53 and change js/customizer.js code to assets/js/customizer.js Don’t forget to … Read more

more than one upload directory?

Using a stock WordPress installation, no. WordPress, by default, stores uploads in the /wp-content/uploads/yyyy/mm/ directory for single sites. For network installations, it stores them elsewhere and maps a similar permalink structure to the new location. I can see what you’re trying to accomplish by keeping things in separate directories, but you’d have to revise a … Read more

Template Hierarchy tag-{slug}.php directory

When you look at the source code, the tag template is loaded as follow in template hierarchy elseif ( is_tag() && $template = get_tag_template() ) : in wp-includes/template-loader.php get_tag_template() uses get_query_template() which uses locate_template() which loads the tag template according to hierarchy from the theme root folder So, moving your templates to a sub-folder will … Read more

wordpress blog in subdirectory or subdomain

The first option (/blog/) is the easiest: create a new blank page called “Blog” navigate to “Settings > Reading” and choose this new page as the value in the “Posts Page” drop-down Now, when you navigate to the new “Blog” page (which should be at /blog/ unless there is something unusual about your setup), all … Read more