The tag has no wiki summary.

learn more… | top users | synonyms

27
votes
4answers
13k 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. ...
8
votes
3answers
1k 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 ...
6
votes
1answer
1k 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 ...
3
votes
2answers
112 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 ...
2
votes
3answers
557 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
790 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
1k 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 ...
2
votes
3answers
3k views

How to prevent wordpress from loading old versions of jquery in wp_head();?

I noticed my twenty twelve theme is including outdated versions of jquery and js so I want to replace the scripts with the newer versions, however the scripts are in the file included by wp_head() ...
2
votes
2answers
106 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
2k 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( ...
2
votes
1answer
233 views

Why does including a file in theme's functions.php not work?

For example, if I write some code (e.d. add a custom post type or something) in my theme's functions.php, it works fine. If I move it to a new file, then include() the file in my theme's functions.php ...
2
votes
1answer
220 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
121 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 ...
2
votes
1answer
82 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
734 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
2answers
3k 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
2answers
2k 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') ...
1
vote
2answers
2k 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', ...
1
vote
2answers
1k 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
1answer
3k 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
584 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
2answers
7k 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
187 views

Should I use include or load_template for including shortcodes, plugins and so on?

I am wondering what is the right way to include additional php files for theme options, shortcodes, plugins and so on. Both load_template and include will work, but what has better semantic value? ...
1
vote
3answers
8k views

Include a external PHP file into a Wordpress Custom Template

Is this even possible? I mean, im 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 custom wordpress template? <?php /* ...
1
vote
1answer
597 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
1answer
734 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
572 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
1answer
89 views

include php file if page_id matches

I think this is a simple question: I'm building a plugi, and up until now, if i wanted to include a php file, i would have to know the page_id - i would put the following command in page.php (or ...
1
vote
0answers
57 views

Jetpack breaks including post (via permalink) [closed]

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
35 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
1k 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
5k 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
44 views

How to include core files into plugin

I did some search about this but I don't realize which is the correct way to include a wordpress core file into a plugin. I wish to include the wp-includes/ms-funcition.php file. For example if I ...
0
votes
1answer
467 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
1answer
1k 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
26 views

Hardening wordpress: blocking /includes with htaccess

This page http://codex.wordpress.org/Hardening_WordPress says this should be included in the .htaccess file to block requests for files inside the includes dir. # Block the include-only files. ...
0
votes
2answers
131 views

Conditionally include files in functions.php?

I have a bunch of functionality being added to a Wordpress site including files in functions.php but I'm worried about performance. All of these files are included for every page request and not all ...
0
votes
1answer
147 views

php include not working in custom page

The Problem I have a db.php file which contains mysql login details. I want it in a separate file like this so it can be linked in several different pages for easier tracing later. This all works ...
0
votes
3answers
1k 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
2answers
56 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
441 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
210 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
821 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
1k 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
575 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
3answers
72 views

Include files in child themes, declare in functions.php

I'm using a child theme. I want to make a change to a file which currently resides in: mybasetheme>includes>sf-content-display>sf-post-layouts.php So I copied the exact same file structure into ...
0
votes
1answer
57 views

PHP help get_template_directory + PHP include

Sorry my PHP skills are lacking. I want to use a php include in WP but I'd like to get the file path with <?php get_template_directory(); ?> I can't figure out how that would look. My non WP ...
0
votes
1answer
50 views

Include a file that has a function in it

I am using include 'filename.php' to load a php file into a template file, simply because the original PHP template file was getting huge and I wanted to split up the sections into different files for ...
0
votes
1answer
47 views

How to query posts to include specific pages of one post type, and all pages of another post type?

I'm having trouble figuring out how to query all posts from the post type "events", as well as including four specific pages in the loop. If I use the "include" parameter, it only returns the ...
0
votes
2answers
64 views

Including php file in directory above WordPress installation

I'm having trouble including an external .php file into my WordPress theme. WordPress installation URL: mydomainname.com/blog PHP File URL: mydomainname.com/testing/assets/inc/analytics.php I'm ...