get_template_directory() returns wrong address on VPS

You can read data on your server with file_get_contents(). If you want to make sure the file exists and is readable then use is_readable(). You don’t really need to use trailingslashit() in this case because you’re constructing the URI yourself. // path to file under current theme $json_file = get_template_directory() . ‘/inc/includes/acf-fonticonpicker/icons/selection.json’; // make sure … Read more

Removing the references to the wp-content folder

It is definitely bad practice to try to move themes (or uploads or plugins) outside of the wp-content folder. WP’s structure ensures that WP can find all the necessary resources. Anytime you move things outside of its structure, odd quirks and broken bits tend to appear. So, stick with /wp-content/themes/your-theme-slug/ and make things more dynamic. … Read more

Failed opening required

WordPress includes many functions for determining paths and URLs to files or directories within plugins, themes, and WordPress itself. $plugin_dir = plugin_dir_path( __DIR__ ); // wp-content/plugins/ require_once($plugin_dir.’WPNonce/WPNonce.php’); While using plugin_dir_path(), keep in mind that the “plugin” part of the name is misleading – it can be used for any file, and will not return the … Read more

Adding regular php file to site

You could accomplish this by setting up a redirect. If you’re using an Apache server, for your example, you would add this to .htaccess above the WordPress block: RewriteEngine On RewriteRule somepost.php ^/somepost/ It’s much more common, and recommended, to create a PHP file and a Page (or other post type) within wp-admin). This will … Read more

Why does WP load so many files in the head of source code? How do I optimize it?

First of all, search this site. This questions has been answered many times in the past: https://wordpress.stackexchange.com/search?q=clean+wp_head and https://wordpress.stackexchange.com/search?q=security+obscurity Secondly, there is a difference in what WP loads and what a theme and a plugin will load. Look in the theme functions file to see what the theme loads, i.e. javascripts and CSS. Look in … Read more