I am developing my WooCommerce theme (hereinafter referred to as WC).
WC does not see the single-product.php template, and load index.php instead. At the same time, on the catalog page, the custom archive-products.php is loaded.
Guys, neither custom nor original single-product.php is loaded. Tell me, please, what to do?
I did:
Create woocommerce directory in theme folder
Inside mytheme/woocommerce I placed custom archive-products.php and single-product.php
I added WC support in functions.php. I checked the support in the site admin panel - everything is ok.
Check the directory again and make sure the file name is correct. it must be archive-product.php Not archive-products.php.
It's better if you copy the plugin template file in your theme directory then modify it.
Example: To override the archive-product.php, copy: wp-content/plugins/woocommerce/templates/archive-product.php to wp-content/themes/yourtheme/woocommerce/archive-product.php
Reference: https://woocommerce.com/document/template-structure/#how-to-edit-files
Related
I want to override woocommerce templates from my theme. I follow all the steps from the official documents of woocommerce. And I'm sure that there is no woocommerce.php file in my theme.
So, I can;t understand why it isn't working.
I'm using twenty seven theme.
Any help will be appreciated.
I had an issue with this relating to the WooCommerce template cache.
The cache can be cleared by navigating to:
WooCommerce > Status > Tools > Clear template cache
If you've already read this documents
https://docs.woothemes.com/document/template-structure/
Please Note: When creating woocommerce.php in your theme’s folder, you will
be unable to override the woocommerce/archive-product.php custom
template in your theme, as woocommerce.php has priority over all other
template files. This is intended to prevent display issues.
Also make sure that you don’t have “Template Debug Mode” activated that you can find under:
WP Dashboard -> WooCommerce -> System Status -> Tools
Try to declare Woocommerce support in your theme's function.php
After lots of researching, finally I've found my answer from here WordPress - Failing to override woocommerce templates
Actually, I use all of my files inside the template folder and this is the reason why it didn't work.
So simple steps. But I can't understand how was I miss it!
Thank's Mo'men Mohamed for your suggetions.
Yes i agree with Mobashir.
There are three steps to check why override not working :
Check in functions.php for woocommerce supported added ( URL : https://docs.woocommerce.com/document/woocommerce-theme-developer-handbook/ )
Check spelling of directory and files is proper in theme such as your-theme/woocommerce. ( URL : https://docs.woocommerce.com/document/template-structure/ )
Woocommerce allow to change the location of woocommerce template. Hook is : woocommerce_template_path .If you are using the premium theme then check for filter hook in your theme's functions.php file. If that hook exits then use that location which is mention in that hook's callback function.
I'm facing the same issue. I am using the JupiterX theme with Elementor and trying to override the checkout template in the JupiterX Child theme, but it's not loading. I have double checked the path, it's like themes/jupiterx-child/woocommerce/checkout/form-checkout.php.
Solution:
I have resolved the issue. Actually, the JupiterX theme has its own WooCommerce overriding structure, that is themes/jupiterx/lib/templates/woocommerce/checkout/form-checkout.php and the same for the child theme that is themes/jupiterx-child/lib/templates/woocommerce/checkout/form-checkout.php.
For more details: themes.artbees.net/docs/overriding-woocommerce-templates
Just want to know that if I'm going to create a new wordpress theme, what about functions.php, should I need to create a new functions file, or just copy it from other wordpress theme. I have read codex but it only tells about the templates needed to create a new theme.
The theme functions file is a template used by Word-press themes. It acts like a plug-in and gets automatically loaded in both admin and front-end pages of a Word-press site.
The functions.php file can be found in your theme’s folder.
You don't need to create a new functions.php file when you want to put your own function in function.php just paste that code in your themes functions.php file.
You can look into these Reference Links to understand more about function.php file :-
Functions_File_Explained
You don't need a new functions.php file if you don't want custom functions in your theme.
See this thread for more information - not including functions.php doesn't make any difference for your custom theme.
I'm facing a very common problem with Wordpress, I don't see the list of my templates in the post edit page. There are tons of posts about this here but I haven't found the solution to my problem in any of them.
I basically have this in my theme directory: index.php, page.php, header.php, functions.php, sidebar.php, style.css
in page.php and index.php, I have:
/*
Template Name: HOME
*/
and
/*
Template Name: PAGE
*/
What I've already tried:
- switched back to the original Wordpress theme and back to mine
- made sure permission 755 was attributed to folder
- copied a working file from another theme and inserted my code into it
- completely logged out and came back
but nothing worked, I still don't see the list of templates for my theme while for official themes, I do see the list of page templates.
Any suggestions?
Thanks
Laurent
You cannot use index.php or page.php as a Page Template, because those files are reserved for other templates of a theme.
As the Page Template reference states:
Name your template file so you can easily identify its Template Name, e.g., filename my-custom-page.php for template name "My Custom Page". Some coders group their templates with a filename prefix, such as page_my-custom-page.php (Don't use page- prefix as WordPress will interpret the file as a specialized page template.)
For information on Theme file-naming conventions and filenames you cannot use, see reserved Theme filenames.
I've just created a website using wordpress and a custom theme for it. This is my theme directory
/themes/customtheme/
-index.php
-header.php
-footer.php
-blog.php
....
The index.php includes header,footer,information to shown on my website, and a link to my blog page.
Blog file will looks same as normal blog site.
May i know how to write a hyperlink(a href) in index.php under theme directory so that it can prompt to the blog.php when click?
If I understand well your question you need to create a new page template using your blog.php file. Just add the following code at the beginning of the file:
<?php
/*
Template Name: My Blog Page
*/
And then create in the backed a new page and associate it to the newly created template.
Read more about page templates here.
Wordpress themes have standard file such as header.php, footer.php, index.php, functions.php, style.css, ...
How to add a php file to wordpress theme addition of standard files? for example I want add a news.php to display specific posts in it, please help me
Just add a new file (e.g. news.php), and put the template comment at the very beginning:
<?php
/*
Template Name: News Template
*/
Then, go to your Wordpress backend, create a new page, and select the template you created: