The include tag has no wiki summary.
15
votes
3answers
6k 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.
...
6
votes
3answers
199 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 ...
5
votes
5answers
3k views
Including jQuery and jQuery files the correct way
I´m having some trouble with this. I´m not sure how to do it the correct way, and I read so many different techniques and ways to do it that I dont know what to make of it.
Some questions and ...
4
votes
1answer
402 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 ...
2
votes
3answers
459 views
where to include a php file
I have a php file with some variables which I would like to use.
When I include it in the header.php the variables in that file are not recognized at footer.php and some other places.
Where is the ...
2
votes
2answers
219 views
What is the most efficient method for loading widgets in functions.php
I have seen WordPress developers use two different methods for loading custom widgets from the functions.php file.
The first:
include("functions/my-custom-widget.php");
The second:
...
2
votes
2answers
75 views
I need to add a custom “cover” to every new post — plugin or custom setup?
I'm creating a site that's basically like an online book, and every post is a chapter. Each chapter gets a customized, specially designed "cover" page that can't really be designed in the Wordpress ...
2
votes
1answer
127 views
Conditional Ajax inclusion
I have a custom interface that uses 30+ ajax files while running...
some files are only used in category.php while othere's are only
used in page.php...
i include the ajax loader php files in my ...
2
votes
1answer
25 views
nowplaying.include.php Will Not Display Results
Cyberchimps.com recommended I post here as they believed there may be a global issue with my request. I thought what I was missing was obvious and simple, but two months into this and being referred ...
2
votes
1answer
318 views
integrating external php library into wordpress- the right way
If I were to load a custom library into wordpress, what would be the best place to add it?
Since there are a bunch of global vars defined at the top of the library, I would not want that to be done ...
1
vote
3answers
2k views
Include a specific page in your template
How do you include specific pages into a template?
Like for example on my websites main page I want to have about 3 different content areas that the client can regularly update as he needs to.
I ...
1
vote
1answer
112 views
ABSPATH not working! Any idea why?
This is what in my wp-config.php :
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
I am calling from plugin/pluginName directory to :
require_once( ABSPATH . ...
1
vote
2answers
988 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 ...
1
vote
2answers
696 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 . ...
1
vote
2answers
460 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 ...
1
vote
1answer
438 views
passing argument to get_template_part() or a better way to code
I have this include … event-list.php
<?php
/**
* The loop that displays upcoming events
*/
?>
<ul class="event-items">
<?php
$yesterday = time() - 24*60*60;
$args = array(
...
1
vote
1answer
63 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
...
1
vote
1answer
242 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 sort by first name. How do I sort this the order the numbers ...
1
vote
2answers
2k views
Include PHP file in Content using [shortcode]
Here is what I have
I am not having any lucking finding how to simply include a file in the content editor using a shortcode.
For Example if I wanted to include form.php inside my Contact Page how ...
1
vote
1answer
595 views
If a page does not exist, include a different page?
I'm setting up a website for a client where they want several different sections, like so:
Regular Site (/)
- Section 1 (/section_1/)
- Section 2 (/section_2/)
...
- Section X
The ...
1
vote
2answers
317 views
Including an External File in a Post (and Using Processed Paths)
I have a post that includes a relatively large table that gets updated frequently. Instead of using the (slower) web interface to update the post each time, I installed one of the “run PHP” plugins ...
1
vote
0answers
38 views
Jetpack breaks including post (via permalink)
On another website, I've been dynamically including posts <?php include '[post].php' ?> via the permalink, from my Wordpress site. I recently installed the Jetpack plugin for my Wordpress site, ...
0
votes
1answer
20 views
Why does abstracting html from plugin code result in loss of access to wordpress functions?
When defining the callback that produces the HTML content for an admin settings page, I'd like to abstract the HTML into a separate file, but the HTML uses some wordpress functions, specifically ...
0
votes
2answers
537 views
How can I include JavaScript that use jQuery on admin side
I try this:
add_action('admin_print_scripts', 'custom_admin_scripts' );
function custom_admin_scripts() {
echo '<script type="text/javascript" src="' . get_bloginfo('stylesheet_directory') ...
0
votes
2answers
627 views
Is it possible to include an HTML flat-file website inside a WordPress theme?
Is it possible to include an entire flat-file HTML site (.html, folders/ and CSS) inside WordPress?
Essentially, I want to host an HTML site, but have access to WP functions and plugins. Not to ...
0
votes
2answers
3k views
Firebug says jQuery is loaded but $() and jQuery() are not defined
I'm trying to test my wordpress page with some simple jQuery script but it won't work.
I've loaded the script with wp_enqueue_script('jquery'); in functions.php as explained in the wordpress guide ...
0
votes
1answer
303 views
bloginfo('stylesheet_directory') vs. get_stylesheet_directory_uri() and include('file.php') vs. get_template_part()
In my custom theme I'm using <img src="<?php bloginfo('stylesheet_directory'); ?>/images/logo.jpg"/> to load my custom logo.
I'm using a custom sidebar for front-page.php and that's why I ...
0
votes
1answer
21 views
is_plugin_active() returning false on active plugin
So I have the following in an include in my theme file:
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
...
0
votes
2answers
32 views
Post's ID pattern?
Each post has an ID and I would like to know how they were assigned. Is there a pattern? Why are the ID's not being incremented by 1 every posts? It would be easier..My ID's go from 9867, to 9869, to ...
0
votes
2answers
243 views
include wp-blog-header not working on MAMP
To clarify my question...
My plugin is/was using AJAX to call the file pluginname/submit/pick.php My pluginname/pluginname.php contains the usual plugin header and wordpress automatically finds it.
...
0
votes
1answer
84 views
PHP files included within functions.php don't work from admin area
I've split my functions.php into multiple files using require_once, which works perfectly. However when I add admin functionality (extra panels) in one of the included files, it doesn't work? It's ...
0
votes
2answers
413 views
Wp Enviroment problem with included file
i have a file i am including across site to index.php, single.php etc.
This file behaves really strage and acts like it not part of
wordpress Enviroment meaning:
i get errors on ...
0
votes
2answers
113 views
Using WP functions such as the_title() in an included php file
I'm including a php file in single.php, in the loop.
Is it possible to use WP variables such as the_title(), the_date(), etc in the included php file?
0
votes
2answers
782 views
Order by & include array by specific post ids
I have the following:
<?php $num_cols = 2; // set the number of columns here
$args = array(
'post_type' => 'testimonials',
...
0
votes
2answers
901 views
confused about wp_list_pages() function - how to display selected top pages with all their subpages
I'm a bit confused about wp_list_pages() function.
Lets say I have 3 top level pages (with no parent) and each of them have some sub-pages:
page 1 [sub-pages: 1.1, 1.2, 1.3];
page 2 [sub-pages: ...
0
votes
3answers
316 views
Looking for a way to include/embed text from a file on a page so that the short codes are processed
I'm using WP as a CMS. I've got multiple pages that share the same header.
group 1 has header 1. group 2 has header 2. etc.
I've looked at these two plugins for a quick way to insert a combination ...
0
votes
1answer
25 views
Is it ok to chop index.php and include files?
So in my index.php I called get_header(), get_sidebar() and get_footer(). My index.php is kind of huge. It is separated into 5 divs more. How do I make it cleaner? Is it safe to chop it to files and ...
0
votes
1answer
67 views
Adding rich text editor to my plugin
Hello Wordpress users,
I'm trying to add a rich text editor to my own plugin.
So I googled it first of course and I found serveral answers like:
...
0
votes
1answer
35 views
file.php not loaded?
I feel like I'm being really stupid.
I want to make use of some functions in wp-admin/includes/file.php (like download_url), but it doesn't seem to be included, not in the dashboard/admin, or in the ...
0
votes
1answer
206 views
Creating plugin using simple_html_dom parser?
I'm running into a problem with my plugin which is essentially an admin page that includes simple_html_dom parser to edit some information scraped from some websites.
Let's assume I want to parse ...
0
votes
3answers
60 views
How and when to include shortcode source files
I am Writing a plugin, with many shortcodes. Now I do not want to include all shortcodes source files to every page. So my questions are:
Where should I include the source? Is it back-end or ...
0
votes
1answer
83 views
Include multiple custom post types [closed]
Hi i want to include 2 different custom post types in my functions files:
include("portfolio/portfolio-post-type.php");
include("gallery/gallery-post-type.php");
But they seem to break ...
0
votes
2answers
162 views
Include doesn't work, getting strange path: (/usr/local/php53/lib/php) - Whats wrong? (WPAlchemy)
I´m using WPAlchemy which is a helper class for metabox creation. I´m trying to include it through my functions.php but I´m getting strange errors when I have WP_Debug set to true.
For some reason ...
0
votes
2answers
327 views
Using plugin_dir_path() with WordPress on MAMP
I have the following directory structure:
Root Install: /Users/philipdowner/Sites/montanaliving
Within the root installation I have the following plugin structure:
...
0
votes
2answers
1k views
Calling a Function in Functions.php from an external PHP script
Preamble
I tried to make sure this question was not asked before. I'm new to using StackExchange so I may have failed in doing so. I don't mind rebukes; thick skin and I learn fast :)
THE PROBLEM
I ...
0
votes
1answer
26 views
add_feed failed to open stream
Trying to add a new feed with:
function events_feed() {
include(TEMPLATEPATH . '/events.php/');
}
add_feed('gpevent','events_feed');
And I'm getting a failed to open stream directory not found ...
0
votes
1answer
52 views
Include file in plugin file
I have a working plugin with many functions in it. I want to break the plugin into several file. I removed some functions and place it in a file called activate.php k7Course.php. Then in the file ...
0
votes
1answer
87 views
Load content From Include File within plugin
The title isn't the best, so feel free to change it to make
it more clear...
Problem:
I am trying to load up a page from within a plugin and replace anything that WP puts out. Have it set so if they ...
0
votes
1answer
1k views
query_posts doesnt show pages with given ID when post_type => page
At the moment I am working on a WP-site, which on the frontpages has 3 excerpts of other pages on it.
The code I am trying to use for this is as following:
<?php query_posts(array('post_type' ...
0
votes
1answer
505 views
including Zend Gdata library path error
I'm trying to include the Zend Gdata module into a plugin, but this error appears on plugin activation:
include_once(Zend\Gdata\YouTube.php) [function.include-once]: failed to open stream: No such ...

