What’s the best way to ‘include’ a file in WordPress?

You can include the PHP files in WordPress just the same way you do it anywhere else. However, WordPress offers more constants and functions for defining a path for the include() function. Instead of using $_SERVER[“DOCUMENT_ROOT”], move your PHP file to your theme’s folder, and use this to include it: require_once ( get_template_directory() . “/data.php”); … Read more

Put CSS inside a PHP file and include it the right way

You might try conditional classes instead. In your regular “style.css” file you would include both classes: .theme-header-title.green { color:green; } .theme-header-title.blue { color:blue; } (Tip 1: avoid !important, just use a more specific style if needed – for example, h1.theme-header-title.green.) Then in your HTML, which is likely in your “header.php” file, you’d use the Customizer … Read more

PHP files included in functions.php don’t seem to work

I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php and pagination functions goes into a file called pagination-functions.php. This way, my code stays organised, managable and I don’t kill my functions.php. This however, is only related to theme specific functions, … Read more

How to include core files into plugin

Most of the time, if you are doing things right you don’t have to include Core files. If you are doing things right they will already be loaded for you. In those case where they aren’t loaded, trying to load files with “directory traversal” paths is the wrong way. The Core constants ABSPATH and WPINC … Read more

Problems Including File

Yes, you can use a /wp-content/mu-plugins folder for single file autoloading plugins. The only thing you will have to do is to use a plugin header comment in this file: <?php /* Plugin Name: I am a MU-Plugin */ Then you will find a link on top of your /wp-admin/plugins.php page that says “Must-Use Plugins” … Read more

Include a specific page in your template

Another great way of accomplishing something like this would be taking advantage of WordPress Custom Post Types. You could set up 3 different types of features for easy use in the WordPress back-end. First, Set up the Custom Post Types To do this, open up your theme’s functions.php file and include something like this: <?php … Read more

the_author() not working outside the loop

I will answer my own question here. The reason the user information didn’t display is because the php tags need the author ID when used outside the loop. For instance the following tag: <?php the_author(); ?> Should be like this: <?php the_author_meta(‘display_name’, 1); ?> This is explain quite well here. Now the code works just … Read more

Include file from higher level

You need to use get_template_directory(), this function will return local server path of you template and then you can use that path to access required file. So in your case it would be something like below: include get_template_directory() . “/Sorting.php”; PS: Mind the spelling of your file.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)