Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [include]

The tag has no usage guidance.

0
votes
0answers
28 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
1answer
11 views

How to include custom PHP file both in header and footer files

I have created a custom file that both the header and the footer needs to render certain content. If I only do include($_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/myTheme/myCustomFile.php'); in ...
0
votes
0answers
14 views

Custom Java Script not working inside Guteberg editor

I try to add a custom java script to my wordpress theme using Gutenberg. In the frontend the scripts are working fine. In the backend (gutenberg) the scripts are included but not taking any effects on ...
1
vote
1answer
97 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 ...
0
votes
0answers
15 views

Difference between using js code referred to earlier and defining the source in the meta of the <script> tag?

sorry if the title is not too self-explanatory, I couldn't find a better title. I am including "bootstrap-select" in my wordpress installation. If I enqueue the script and later try to use it I get ...
0
votes
0answers
11 views

Homemade global template, advice?

For the theme I’m using there is a hook for an area just above the footer section and here I would like to output different ”banner sections” that are ”prepared globally”. So for each ”banner section”...
0
votes
2answers
23 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 ...
0
votes
0answers
42 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 ...
1
vote
1answer
566 views

How can I defer these JS files?

In my website, I used GTmetrix and I got JS defer error on following two files. 92.5KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page ...
1
vote
1answer
75 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 |...
0
votes
0answers
14 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
1answer
35 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
0answers
50 views

property=“og:image” doesn't register with including a php file as a shortcode in WP Post and Pages

I would love some help or a direction to a point of solid research on this issue. From what I understand, and my current research, wordpress by default out of the box does not support php files to ...
0
votes
1answer
27 views

Can not include file from plugin into theme

I want to include file from a plugin to templates function file. This is the code i use : $acf_url = plugins_url('/advanced-custom-fields/acf.php'); include_once($acf_url); But this code is not ...
0
votes
2answers
145 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, "...
-1
votes
1answer
591 views

php “use” not working in template [closed]

I am trying to implement code from this site and in the code the following line is causing an error and my page is not loaded -- use \Aws\Polly\PollyClient; If I comment the code out then the page ...
1
vote
0answers
443 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
votes
1answer
472 views

How do I fetch a data from an external database into my wordpress homepage

I have a WordPress site installed in a subfolder of my host and another php-based custom written CMS in the public_HTML. I'll like to fetch some data (a marquee text to be used on my WP theme header) ...
0
votes
1answer
22 views

What is the proper way to include a PHP framework into my theme?

I am using a Twitter Timeline PHP framework to display a list of tweets with favorite/retweet interactions. I have it all configured and working as a standalone solution currently and I am wondering ...
0
votes
1answer
55 views

Can I have an additional functions.php file in Wordpress?

There're quite a lot of functions, and so, does my theme, it all gets a little cluttered even with all the comments. Additionally, every time the theme is updated, the new functions.php file would ...
-2
votes
1answer
39 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. ...
0
votes
1answer
49 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
1answer
91 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 ...
-1
votes
1answer
818 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 ...
0
votes
2answers
193 views

Impossible to call wordpress function inside an include?

In my Plugin, I have an object 'Settings' (to display stuff in Wordpress settings). Settings.php <?php namespace FooNamespace\Admin\Settings; class Settings { public $menu_slug; ...
1
vote
2answers
38 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
1answer
305 views

What's the best way to 'include' a file in WordPress?

Ive built simple web applications in the past using 'include' functions and typically I've used this command: <?php include($_SERVER["DOCUMENT_ROOT"] . "/data.php"); ?> This has worked great ...
1
vote
1answer
748 views

locate_template function - File not getting included

$locate = locate_template( 'widgets/the-post-widget.php' ); I am using the above path and method to include a file in functions.php, but that is not happening. The file doesn't seem to include. Am I ...
-1
votes
1answer
83 views

White Screen When Includding A Folder With PHP Files

So I'm currently working on a plugin using the boilerplate plugin structure. The problem comes up when I try to include a folder full of files that are needed for my project. I go to the admin class ...
0
votes
0answers
266 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
1answer
262 views

Including admin-options.php file in Child Themes

My theme uses the following in functions.php require_once get_template_directory() . '/includes/admin-options.php'; I want to override this with my own version of the admin-options.php file, which ...
0
votes
1answer
75 views

Unable to point the child theme directory even using get_stylesheet_directory()

I am developing a child theme based on storefront as parent theme. I am trying to include files in child theme functions.php file as: require_once get_stylesheet_directory() . '/inc/_customizer.php'; ...
7
votes
2answers
4k 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 ...
1
vote
2answers
1k views

functions.php is being included twice, creating PHP fatal errors

I have a custom PHP script (which is importing Wordpress via wp-load.php) that I've used successfully on many sites in the past, yet it's misbehaving on one particular site seemingly after a couple of ...
2
votes
2answers
314 views

Include Javascript as Plain (No file inclusion)

Is there a way to append Javascript to the body in the script tag without using a file? Normally you would do it with wp_enqueue_script('name', 'path/to/js/file'); Is there a way to include js ...
0
votes
2answers
108 views

PHP include is only working in certain places in my custom WP theme

I am building a site using a custom WP theme, and I have been using: <?php include('header-bar.php'); ?> in order to include a navigation bar on each page. I intentionally didn't put the ...
0
votes
1answer
187 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 ...
2
votes
1answer
3k views

Passing variables to template parts

I have one template file videos.php which has the following line of code in it (aswell as a load of HTML): <?php get_template_part('loop', 'feed-videos' ); ?> inside that template part, I have ...
0
votes
1answer
185 views

Can I include a custom PHP function in a Wordpress function?

I'm trying to add a shortcode in my Wordpress functions.php file. I want the short code contents to be sent to a PHP function from another part of the website. This is the code: function short_api($...
0
votes
0answers
40 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
0answers
77 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
1answer
33 views

How to get the form code from the edit page of a specific post?

On a site I'm working on, in the profile page - for example - I have to display the content from a few custom posts (additional details, location details, billing). And instead of having the user ...
0
votes
1answer
311 views

Having trouble linking to file using relative path

I’ve created a widget plugin and have placed the code for displaying the front end content in a separate file. I’m linking to the file using include_once but keep getting the error, failed to open ...
0
votes
1answer
56 views

How can I include an external file in a post or page?

I have some text blocks which are used various times. I want to be able to add them as txt files to a folder in my theme, and then add one to specific posts and pages with either a shortcode or ...
1
vote
1answer
74 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 ...
3
votes
2answers
473 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', '...
29
votes
2answers
47k views

get_template_directory_uri pointing to parent theme not child theme

The problem I am having is that the get_template_directory_uri is pointing to the parent theme like site/wp-content/themes/twentythirteen/myGallery/gallery_functions_include.php but I want it to ...
1
vote
2answers
133 views

Problems Including File

I read that if you create a php file and save it in the /wp-content/mu-plugins/ directory, WordPress will auto-load it. However, I haven't yet figured it out. I don't have a folder named mu-plugins; ...
1
vote
1answer
1k views

Automatically include all php files in a child theme directory

I'm currently using a custom child theme across multiple sites, and would like to modularise particular custom features (e.g. ecommerce) by separating them into individual php files, and including the ...
0
votes
2answers
893 views

Push Shortcode parameter to template

I'm trying to push a shortcode parameter value to a template file but for some reason I can't get the array value that I'm targeting into a single variable. Here is my code and the shortcode I'm using:...