I have a file order.php exist at "website/order.php".
Question
I want to include header.php file into order.php file that exist at website/wp-content/themes/template/header.php . I am using this code in order.php file, but it is not working
include('wp-content/themes/business/header.php');
you can write below code:
include "wp-load.php";
get_header();
Related
I could not find a .pot file so I created one with Eazypo. There was no languages folder in the theme folder either. I created a "languages" folder and uploaded the newly created .pot file. I translated every string and uploaded the new .mo and .po files in the "languages" folder and I defined wp lang to have the value of the .mo file name. Not working.
Any ideas of what can be wrong or how to solve this issue?
Thank you
In order for your theme to load your translation files, you need to use the load_theme_textdomain() function.
Add the following code to your theme's functions.php file:
function wp756531_my_theme_setup(){
load_theme_textdomain( 'my-theme', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'wp756531_my_theme_setup' );
Important Notes:
Make sure to change the 'my-theme' domain to the one your theme uses.
Make sure your translation files are named after your locale(s) (eg. es_ES.mo, sv_SE.mo, etc)
From a PHP template file located in a sub-folder of my WP theme folder (my_theme/subfolder/my_file.php) I want to use get_header() and call a custom header-new.php located in the same sub-folder.
Instead, get_header(header-new) loads header.php located in my theme root folder. How to fix that problem?
You are correct to use get_header() function. However, as per documentation you should pass the name of the custom header in the specific format - only the part that comes between 'header-' and '.php'. E.g. for the custom header in the file:
header-custom.php
you should use:
get_header('custom');
But that's not all. It is important to remember that the custom header file should be placed in 1 or 2 specific directories, depending on whether you're working on parent or child theme:
Parent theme: you should place it either in the same directory as the page template or the 'root' theme directory (specifically the same directory where your style.css is)
Child theme: you have to place it in the 'root' child theme directory
get_header() function calls locate_template() function, which searches for the custom header file in those 2 directories. If it doesn't find the file, it defaults to 'header.php'.
you can use :
get_template_part('header-new.php');
reference here: >https://developer.wordpress.org/reference/functions/get_template_part/
I am developing a plugin and it works fine when I call my code from my plugin's main php file but I want to run only once My external file is called in the plugin. I mean I want to place my function inside includes folder and in a file living there. like plugin folder/includes/file.php ... here is my code
add_filter('wp_nav_menu_items',',my_custom_function');
function my_custom_function ($nav){
return $nav."<li class='menu-header-search'><a href='#'>Icon</a></li>";
}
Kindly let me know how can I make it work, it works in side plugin's main php file but does not work from other php files inside plugin includes folder.
It should work if you include your file from the plugins main file, just make sure it is included correctly.
include plugin_dir_path( __FILE__ ) . 'includes/file.php;
This would include a file in an includes folder in your custom plugin folder, and would include an file named: "file.php". If you want to know if its been loaded correctly, just add an die() statement in the included file:
die('my include file has been loaded correctly');
Just remove the die() statement after you have an confirmation that its working :) Lastly you need to copy your callback function code and paste it in your included file. If your hook still does not work, then it might be something wrong with your callback function.
The documentation for the filter hook you are using:
https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
How to create a new file in my wordpress theme without using ftp client ?
thanks !
Using touch(); PHP function, which creates a new file in the specified directory. This is how I suggest doing it (and admittedly, there are cleaner ways, but this will get the job done, quickly and effectively)…
Open header.php — then write this code in the very top of the file:
<?php touch('wp-content/themes/YOUR_THEME_DIR/FILE_NAME.php');?>
Replace YOUR_THEME_DIR with the directory in which your WordPress theme lives.
Then, replace FILE_NAME with the name of the file you want to create.
Once that’s all done, save Header.php and go to the homepage of your site.
As soon as the homepage loads, it will create that new template or theme file.
Source :
https://www.webmechanix.com/how-to-create-a-new-theme-file-in-wordpress-without-ftp-access/
You can use a plugin called WPIDE found here https://wordpress.org/plugins/wpide/
This plugin will allow you to edit and add folder and files in your project.
I am trying to find where my Wordpress theme calls the CSS file but should it be in header? I have checked there and cant see any reference to it.
Any properly coded theme should register/enqueue scripts and stylesheets via the wp_enqueue_scripts hook. This should all be in your functions.php file or any other file that is called into the functions.php file
You can just do a search inside your functions.php or functions related files. You should never add scripts or styles directly inside your footer or header
In WordPress You Don't Want To Give css file path .It has pre define css file path in function.php file.
If you change css file structure then you want to change style file path in function.php file.
and also add your new style.css file with.
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/yourcssfilename.css">
www.sitename\theme\wp-content\themes\themename\css\yourcssfilename.css