Questions tagged [include]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Displaying page content from plugin, inside exising empty WP page

Old php developer here, very.. very new to WP, so be kind. I am building my first WP Plugin. I have this in the plugin central file (the one that is /plugins/my_plugin/my_plugin.php): // Setup the ...
user avatar
1 vote
2 answers
214 views

How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?

In a plugin I am currently coding, I want to use the Simple HTML DOM Parser library. However, when I include it require(CPS_PLUGIN_PATH . '/vendor/simple_html_dom.php'); I get this error: Fatal error:...
user avatar
0 votes
1 answer
18 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 ...
user avatar
  • 985
0 votes
1 answer
32 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/...
user avatar
0 votes
0 answers
31 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 ...
user avatar
0 votes
0 answers
152 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....
user avatar
2 votes
0 answers
45 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; ?>";<...
user avatar
0 votes
1 answer
45 views

Use $variable from file1.php in file2.php (different file paths)

I have $variable_1 = '5'; in /public/includes/themes/theme-section-users-score.php and I want to use its value in another php file with a different location /plugins/name/other/users-time.php , I ...
user avatar
0 votes
1 answer
143 views

require get_template_directory() . 'path/to-my/file.php' BREAKS customize > themes functionality

hope to get some help, please <3 i'm building a theme from scratch as an exercise to learn WP and PHP, using WP commercial themes (GeneratePress and WP default themes) as a guide. when i use: $...
user avatar
0 votes
1 answer
69 views

Adding a second loop breaks everything

I have a page template that has the following: <?php get_template_part( 'include', 'certifications-popular' ); ?> Within this file, I have two loops. But having the second loop in there seems ...
user avatar
0 votes
1 answer
147 views

include specific Pages to wp_list_pages with filter

How can i make a simple filter to display only specific pages (include instead of exclude) as an output to wordpress pages widget? I made this code , but its not working function specific_pages($...
user avatar
0 votes
1 answer
105 views

I'm including a html file in my plugin, but it can't find its css or js files

I'm writing this little plugin and my php file at one point includes a small html file, like this: function draw_editor(){ include HANDLER_INCLUDE_URL.'/draw.html'; } But the problem is, that ...
user avatar
  • 113
0 votes
0 answers
22 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?
user avatar
  • 985
0 votes
2 answers
2k views

get_template_part for template in subdirectory not working

I'm working on my first wordpress site, and moving it online. I have been adding some extra templates to design a simple booking engine, that was working perfectly on my offline localhost server. ...
user avatar
  • 1
0 votes
0 answers
24 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 ...
user avatar
1 vote
1 answer
2k views

Put CSS inside a PHP file and include it the right way

I want to put CSS inside a PHP file, because with that I can use 'conditional CSS', depending on the value of a customizer control. My idea is to create a new php file, somewhere in my theme ...
user avatar
0 votes
0 answers
37 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(...
user avatar
1 vote
1 answer
91 views

code is skipping a div

In header.php I have created a div to contain my navigation menu area. Within the div is 1 x do_shortcode and 2 x includes php files. For some reason the last include ('custom-primary-menu.php') is ...
user avatar
  • 139
0 votes
0 answers
123 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 ...
user avatar
0 votes
1 answer
55 views

Before & After Content - After Content directly below Before Content when using require_once

I've encountered an issue that I can't seem to figure out. I am using require_once to place content before and after the page content on my homepage. The before content works perfectly and displays ...
user avatar
2 votes
1 answer
59 views

Can I change a variable in a content part while calling it?

I am using a content part for title sections on various sites. I would still like to be able to change the title manually on each page. For this particular case I can‘t use dynamic functions like ...
user avatar
  • 23
0 votes
0 answers
78 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 = ''; $...
user avatar
0 votes
1 answer
910 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 ...
user avatar
  • 103
1 vote
1 answer
909 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 ...
user avatar
0 votes
2 answers
272 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 ...
user avatar
0 votes
0 answers
835 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 ...
user avatar
1 vote
1 answer
3k 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 rendering....
user avatar
  • 376
1 vote
1 answer
1k 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 |...
user avatar
  • 23
0 votes
0 answers
60 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 ...
user avatar
  • 172
0 votes
1 answer
74 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-...
user avatar
  • 245
0 votes
1 answer
290 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 ...
user avatar
  • 325
0 votes
2 answers
4k 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, "...
user avatar
-1 votes
1 answer
3k 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 ...
user avatar
  • 176
1 vote
0 answers
1k 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 ...
user avatar
  • 11
0 votes
1 answer
2k 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) ...
user avatar
0 votes
1 answer
32 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 ...
user avatar
  • 363
0 votes
1 answer
722 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 ...
user avatar
-2 votes
1 answer
260 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. ...
user avatar
  • 7
0 votes
1 answer
274 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; ...
user avatar
  • 770
0 votes
1 answer
424 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 ...
user avatar
-1 votes
1 answer
2k 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 ...
user avatar
1 vote
2 answers
819 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; ...
user avatar
  • 770
1 vote
2 answers
43 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 ...
user avatar
1 vote
1 answer
915 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 ...
user avatar
  • 985
1 vote
1 answer
2k 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 ...
user avatar
-1 votes
1 answer
139 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 ...
user avatar
0 votes
0 answers
657 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 ...
user avatar
0 votes
1 answer
524 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 ...
user avatar
0 votes
1 answer
108 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'; ...
user avatar
9 votes
2 answers
8k 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 ...
user avatar
  • 187

1
2 3 4 5