+92 308 5039935
Get a Free Quote
+92 308 5039935

How to Auto Load Files in WordPress?

How to Auto Load Files in WordPress?

You may need to auto load files in WordPress themes or plugins. But I wouldn’t recommend it if you are creating theme to sell on themeforest. They didn’t accepted themes with this auto load function few years ago when we used to sell themes on it. Here is the function to auto load or require files.

Now if you want to auto load .php files from includes folder in a theme you will use it as following.

 

If you need to exclude a certain file like say index.php from that folder, you just need one extra line inside foreach to check if the file name is index.php then tell it to continue; to other file.

 

Hello, I am a web designer and developer working since 2013. I build WordPress themes, write and extend WordPress plugins, edit WordPress themes and plugins in accordance to customer needs and play games when free ;-)
Related Post
Minify CSS
How to minify CSS in WordPress Theme or Plugin

Minification is used to remove unnecessary elements, e.g: extra spaces. There are a lot of php scripts to minify or compress the css but we are going to use a simple function  here. It is usually used for inline css in WordPress.

Read more
How to add inline CSS in WPBakery Page Builder Element

WPBakery Page Builder (Formerly Visual Composer) is one of the best drag and drop front-end/back-end builder. You can easily apply inline css using style attribute but what if you need to apply css to a pseudo elements?

Read more
How to create WordPress plugin

Plugins are used to extend WordPress functionality or add a new feature. There are more than 54K+ plugins available free at WordPress Plugins directory and tons are available at other markets places.

Read more
Post has 2 comments
  • Ignacio Mojica Posted February 16, 2020 in 8:27 am Reply

    Great content! Super high-quality! Keep it up! 🙂

  • Kathryn Perkins Posted January 29, 2020 in 6:11 am Reply

    Awesome post! Keep up the great work! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *