Questions tagged [include]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
56 votes
7 answers
52k views

Passing variables through locate_template

While I've typically used include or require on their own to save long term code maintenance I've started to use get_template_part and locate_template as using built in WordPress stuff is always best. ...
curtismchale's user avatar
  • 2,599
3 votes
2 answers
235 views

How can I avoid code duplication for a blog with lots of source code?

I'm writing a tutorial on using the R language to do some applied statistics. An example post is: http://mcmcinirt.stat.cmu.edu/archives/223 I would like to have all of the blocks of source code be ...
Nathan VanHoudnos's user avatar
2 votes
2 answers
3k views

Show certain terms from custom taxonomy but exclude 'parent' terms?

I have a custom post type "mycustom_products" (hierarchical) that has custom taxonomies called 'categories' and 'tags' (as many other custom post types do). My custom category is called "...
RodeoRamsey's user avatar
  • 1,707
2 votes
1 answer
228 views

Include files for a plugin not including

I have a plugin which I need to include a file in but it doesn't include. Here's the example of the tree: plugin folder /themes /folder2 /somefiles /includeme.php Within themes is /...
equilibrium3's user avatar
-2 votes
1 answer
11k views

How to rename wp-includes folder?

Is there a way that we could rename wp-includes folder I have found out there are ways to do for other folders. But how do we do it for wp-includes folder? http://pythoughts.com/how-to-hide-that-you-...
Raghav's user avatar
  • 123
32 votes
3 answers
34k views

Is there any way to use get_template_part() with folders?

I'm wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I'd like to put them in ...
Paul's user avatar
  • 2,150
14 votes
3 answers
89k views

The proper way to include/require PHP files in WordPress

I'm a new WordPress developer and recently I've been having problems (on multiple sites) with include_once and require_once for PHP files. If I include (get_theme_directory_uri() . 'subdir/file') the ...
caffeine's user avatar
  • 141
11 votes
2 answers
9k views

Include WP_Query in my own PHP file?

I want to write a cronjob for myself. But I need to get access to WP_Query and the permissions to delete posts etc. My question now is, how can I include the WP_Query function to my own PHP file and ...
Jan's user avatar
  • 307
10 votes
1 answer
4k views

Should we use get_template_part() in functions files instead of include_once?

I'm using the theme-check plugin to check my theme for errors and recommendations, I'm using get_template_part() in theme files like header.php and index.php but in functions.php I'm using ...
Pierre's user avatar
  • 1,014
7 votes
6 answers
88k views

Include a external PHP file into a Wordpress Custom Template

Is it possible to include a external PHP file into a custom template? I'm trying to add a blog into my site. I already have the header, footer, and sidebar layout in my site. Can I use those in my ...
Jeremi Liwanag's user avatar
4 votes
2 answers
636 views

load/require specific php files for specific pages/templates/post types

I have a plugin with multiple php files. I want to load some of them only when specific template files are loaded. I don't want to load everything. Currently, I'm doing it with add_action( 'wp', '...
eddr's user avatar
  • 41
4 votes
1 answer
6k views

Problem requiring/including plugin files with plugin_dir_path( __FILE__ )

I am trying to write a WordPress plug-in. In my project I have three PHP files. My plug-in file Widget for the plug-in Data installation I need to install data table on plug-in activation. For that ...
Bushra Shahid's user avatar
3 votes
3 answers
2k views

Sort users in get_users() in custom order

<?php $blogusers = get_users('include=5,6,2,7,12,8'); foreach ($blogusers as $user) { ... } ?> Right now, these users will sorted by first name. How do I sort this in the order the ...
nicolas's user avatar
  • 265
1 vote
1 answer
1k views

Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons

I’m trying to change the svg of the ellipses for the mobile menu. It’s called in this file: template-functions.php so I did a hook on my child theme functions.php to replace it, like so: function ...
Duarte Nunes's user avatar
1 vote
1 answer
267 views

How to include template according to meta post value

I'm trying to include a particular template according to the meta value stored for example: If the post meta value is value1, I want to include different template and if it's value2, I want to ...
Ashish Pariyani's user avatar
1 vote
2 answers
5k views

WordPress "include TEMPLATEPATH" or?

I built something like this: Index Container Widgets Area and I created a widget for that - Categories Widget - Index Container .php with this in: <?php include (TEMPLATEPATH . '/includes/...
Fnarp's user avatar
  • 65
1 vote
4 answers
12k views

Adding rich text editor to my plugin

I'm trying to add a rich text editor to my own plugin. So I googled it first of course and I found several answers on dev4press and Stack Overflow. This code displays nothing so I tried another ...
Ronny Rook's user avatar
1 vote
2 answers
666 views

What's the correct way to include files in Wordpress TwentyTen theme with it's own jquery scripts and css?

I want to include a slider in the default Wordpress theme on the home page. I did manage to get the page to show using <?php if ( is_home() ) { include ('slider.php'); } ?> but it doesn't look ...
Diventare Creative's user avatar
0 votes
2 answers
367 views

Using Includes in Templates in Document Head

In a template, I have a need to include_once an external PHP (an include.php) that contains functions that I need to use inside the template. Included in those functions are CSS styles and an ...
Rick Hellewell's user avatar
0 votes
1 answer
344 views

How to include class from addon after to be sure one class exists in the main plugin?

I have a plugin Foo. In this plugin, my main class can include several classes one of which is a useful abstract class named Heading. Foo.php - my main class from my plugin Foo namespace PluginFoo; ...
J.BizMai's user avatar
  • 850