Questions tagged [include]
The include tag has no usage guidance.
50
questions with no upvoted or accepted answers
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', '...
2
votes
0
answers
176
views
Change title and meta description in included page (not template)
I'm trying to change title and meta description for pages used for products.
The goal is to have the same effect as here:
<script>document.title = "<?php echo $new_title; ?>";<...
1
vote
1
answer
2k
views
get_option() not returning expected value from plugin
I am trying to make my first plugin, and so far everything has been fine except one little annoying thing. I have my fields setup and updating data and looks just fine in my database:
mfwp_settings |...
1
vote
0
answers
2k
views
Override file inside inc in child theme
I want to make a child theme of hesita. This theme has templates in the inc/sections folder and I would like to load these from my child theme instead of from the main theme.
Tried to copy the files ...
1
vote
2
answers
49
views
Use of Templates in a Plugin
I´am creating a Plugin. For this I wrote my own templates. Now I want to have the templeates files in my Plugin directory.
But that doenst work fine. Since I used the Plugin directory, wordpress ...
1
vote
1
answer
133
views
WP Plugins - Use includes to display page content
So I have a plugin I have been working on. It adds a menu and multiple submenus.
Each submenu page contains a form, this form is created in a function called add_content_submenupagename. This ...
0
votes
0
answers
12
views
Wordpress Includes mejs 404 error
I have an issue with NewRelic reporting a number of 404 errors which all stem from the WP includes mejs
Example of the 404 error
site.com/mejs.hebrew
& site.com/mejs.dutch
Has this occurred for ...
0
votes
0
answers
37
views
Display file contents within Plugin
Does anyone know what I am doing wrong - I try to display forms from different files within my plugin. all is triggerd by my_shortcode where the via $atts the user choses which form to display. This ...
0
votes
0
answers
57
views
WP-Include rewrite directory
I try few day to rewrite wp-include directory but not success.
In .htaccess I add next line
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^main/(.+) /wp-includes/$1 [L,...
0
votes
0
answers
109
views
How to include a php file in 404.php file?
I have created a log to track some attacks on a website. At the moment I have included it directly in the 404 file like this:
<?php get_header();
global $porto_settings;
require_once(ABSPATH.'...
0
votes
1
answer
22
views
Pull in an "Include" file based on a WordPress Category ID
Here's what I am trying to achieve: when a category page is loaded then, based upn the ID of that category, an "include" file is loaded.
I believe that the below would work for some limited ...
0
votes
1
answer
96
views
Why should I use get_template_directory() when include files?
When I include files in wordpress I noticed that include works fine without get_template_directory(). Include even works fine without parenteses.
include( get_template_directory() . '/includes/front/...
0
votes
0
answers
35
views
Wordpress functions.php conditional include another functions file
In my wordpress functions.php I have calls to include other function files. For example like so:
include("functions/articles.php");
include("functions/custompost.php");
Within ...
0
votes
0
answers
279
views
FPDF for creating pdf diplomas
Before anything else, I must say I am new on building WordPress functions. I have a website with online courses. Students have to sit exams and at the end they get a score, an average of all the exams....
0
votes
0
answers
27
views
What about "inc" (include) files and Child Theming? Is it possible?
What I mean is that I'd like to add "inc" files that are not overwritten when there's an update. Is that even possible?
0
votes
0
answers
29
views
Should I use include(_once) or require(_once) for loading php-file with customizer settings?
Should I use include, include_once, require or require_once to load my customizer.php file? That file has all customizer settings and code in it. What is your advice on this?
The file is currently ...
0
votes
0
answers
45
views
"Cannot modify header information - headers already sent by" while using get_stylesheet_directory_uri()
I have a very strange problem while trying to include a custom file to my child theme. if I try to use get_stylesheet_directory_uri() along with require it crashes the website. if I try to var_dump(...
0
votes
0
answers
138
views
How can I include custom Gutenberg Blocks in a theme?
I know that officially Wordpress wants people to include blocks as companion plugins, and I understand their reasoning for that.
I am building a theme with a very specific usecase though and I would ...
0
votes
0
answers
130
views
Including content into an add_shortcode() function
my_html.php
<?php
global $wp;
$op = get_option( 'mcc_d' );
$post_title = get_the_title();
isset( $this->op['mcc_d_text'] ) ? $mcc_d_text = $this->op['mcc_d_text'] : $mcc_d_text = '';
$...
0
votes
0
answers
1k
views
How to add variables to a template
I am using a query argument detail to check if a custom template should be loaded. This works fine, but I also need to add some variables that can be accessed from within the template. Here I am using ...
0
votes
0
answers
68
views
How to include files in the loop via ajax
I create plugin and I need to include multiple files via ajax.
When I don't use loop this code work:
include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'sections/a.php' );
When I try to ...
0
votes
1
answer
76
views
Make changes in /includes/http.php update safe
I've commented out the following two lines in the http.php,
function send_origin_headers() {
$origin = get_http_origin();
if ( is_allowed_http_origin( $origin ) ) {
// @header( 'Access-...
0
votes
2
answers
6k
views
loading a php file to a specific page id
I'm trying to assign a php file to a specfic page?
I have modals stored in different files and want have them load in when their assigned page is called. These pages are using the same theme, "...
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;
...
0
votes
1
answer
513
views
Multiple Taxonomy post query with exclusion
I have multiple taxonomies for a custom post type ('product') and I would like people to select from the list whether they want to include one or more of the terms and if they want to exclude one or ...
0
votes
0
answers
688
views
PHP get_category() function redeclared
I'm not a developer, hence why i'm asking for the help of you experts :).
I was assigned the task to move a wordpress website (From apache with php 5.4.45 to IIS with PHP 5.6). Once migrated I'm ...
0
votes
1
answer
281
views
Need to override file included in parent theme
I am using a parent theme with built in reservations which is a modification of a reservations plugin by a different developer. It didn't do exactly what we needed we needed so we purchased the ...
0
votes
0
answers
51
views
How to write wordpress plugins faster to load?
I am writing a wordpress plugin
The problem is this plugin effecting website performance.
I need tips to make my plugin faster, any help would be amazing.
My plugin contains several classes and I am ...
0
votes
0
answers
93
views
Class works in Admin, not found on Front End
I'm using the SendGrid PHP library to send transactional emails on submission of new posts by the user, a simple submission received.
In the admin, it works perfectly. On the front end I get a class ...
0
votes
1
answer
35
views
require happens out of order
I have a page template that is including another file via require_once. I want this included file to have access to the $post object but it can't find it.
So I ran something like this to see what's ...
0
votes
0
answers
29
views
Creating Action Hooks For Automatic File Inclusion
I want to create a hook for automatic file inclusion in my plugin, but I am finding my stuck moments. May be somebody could help me out. Here is what I tried:
$args = array(
"url" =>""
);
...
0
votes
0
answers
113
views
how to include js in widget?
I know about wp_enqueue_script. i just wanted to make sure that it applies here. I built a custom widget that uses a lot of js. Most of that js is included in a separate file that gets included from a ...
0
votes
0
answers
2k
views
Using require_once for parent-directory not working but is working in sub-directories
I'm building a custom theme and I'm attempting to use require_once __DIR__ . '/templates/variables.php' in my footer.php file, to keep from repeating code that contains variable information... I keep ...
0
votes
2
answers
460
views
if statement parent page for child pages
im trying to achieve a code to include a file into pages, these pages has a parent page.
so instead of repeating the code of the "if statement" i use this function but doesn't work.
i want any page ...
0
votes
0
answers
176
views
sharing wp-include - wp-admin on same installation
This is not a security or privacy issue..
I have multiple wp installations (usually a couple for project),
so in the next installation I'll be setting up I'm thinking of cutting down some space ...
0
votes
0
answers
545
views
template_redirect and title
I pass a template_redirect in wordpress as hook but I want to have a personnalized title for this page and I miss to do that.
Has someone any idea ?
add_action( 'template_redirect', 'virtual_pages' );...
0
votes
1
answer
56
views
Include post on external custom site
How do I include single post ( I mean image, title, and a bit of text ) on my own custom site?
I have wp in subdirectory and I just want to make "Recent article" box on my site.
I was looking for it 2 ...
0
votes
1
answer
537
views
add_action outside a plugin
I'm trying to create my own class to make some of the most common changes I need in all my WP sites. Things like removing the canonical tag when not required or changing the meta description.
I'm not ...
0
votes
1
answer
48
views
Include inside sidebar
Is it possible to include a file inside or inbetween items in a sidebar?
Here are the two functions being called:
<?php get_sidebar(); ?>
<?php get_template_part('testimonial-box'); ?>
...
0
votes
1
answer
68
views
Include a php file that is above WP installation hierarchically?
I've come across a number of ways to call the WP "root" folder
But what if I want to include a php file that is in a parent folder of WP?
Example http://www.site.com/, where the WP blog is in http://...
0
votes
0
answers
1k
views
show Visual form builder in the front end
Iam anew in wordpress . i used this plugin http://wordpress.org/plugins/visual-form-builder/ to build custom pages then i tried to build a custom page called formbuilder.php to use it in the front end ...
0
votes
2
answers
79
views
Undo a function that is not (seemingly) hooked to an action?
I am using the popular Disqus plugin. To use this plugin effectively, they advise you to change the URL on the front page to end in #disqus_thread. I know how to easily do this in jQuery, but I ...
0
votes
1
answer
117
views
Include paths and functions for external scripts
I try load external script as plugin , the idea it´s use one easy plugin and call script and load this script into admin but i have problems with some configuration files and css files , in the case ...
0
votes
1
answer
110
views
post content includes and seo vs. duplicate content
Trying to find the answer here but can't seem to locate this specific scenario...
We have products that include multiple, defined resources - for example, each has 3 distinct user guides for ...
0
votes
1
answer
198
views
Add page as static html into another page
Is there a way to include a wordpress Page into another one? I'm not just talking about getting the content using get_page(), but to import the whole page (theme + content). I have been looking around ...
0
votes
1
answer
41
views
Wordpress blog set up
I plan to launch my website with multiple blogs plugged into it, with a main index page for all posts.
I currently have the index running from the root and two blogs running within their own folders ...
0
votes
1
answer
156
views
Custom meta box includes
I am having some problems including files for my custom meta boxes. I have a structure like so:
post-meta.php
cmb
teaser_meta_box
load.php
initiate.php
display.php
save.php
So within my post-...
-1
votes
1
answer
3k
views
Shortcode to include PHP file, pass various parameters to include?
Want to include php file in WP content. Some parameters will be different depending on the include.
I want to write 1 include shortcode. I do not want to write different include functions for each ...
-1
votes
2
answers
147
views
wordpress.org disallowing my plugin becuase of loading core files in cron cpanel file
I made a plugin and trying to install on wordpress.org but Wordpress is giving me error message that ## Calling core loading files directly is incorrect.
I am using a cron file in my plugin.This cron ...
-2
votes
1
answer
539
views
Javascript file not included only on home page
I have problem with loading my own javascript file, this problem is only on home page, on other pages it's ok.
Right now I've problem with interactivity, because only on homepage I can't do that.
...