Woocommerce template overriding not working - wordpress

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

Related

WooCommerce not including template single-product.php

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

Buddypress template hierarchy is not being used

I am updating an installation of buddypress (1.5) to the most recent version (2.1.1). I have updated the files and am now trying to update the theme to use the template hierarchy pattern.
For this I created the following directory structure within my theme:
my-theme/
buddypress/
groups/
index-directory.php
index-directory.php contains a single die('debug') statement for testing.
If I copy this buddypress directory into the twentyfourteen directory and activate that theme, I am seeing the debug message when I'm on the group listing page. However, when I use my custom theme, the message is not showing up.
This tells me that the template hierarchy is not being applied on my theme. Why could that be?
I suspect that somehow my theme is being treated as a legacy theme, I don't understand why though. I commented out the whole functions.php to make sure it's not because of aynthing in there. The header comment in the style.css does not contain anything special either.
Any help on this?
Thanks.
The problem was my own mistake. Our theme stylesheet had a Template: bp-default in it. I didn’t notice it at first because our theme is named similarly and my mind read it as the title of our theme. If I remove it, my templates are included.
For anyone stumbling on this problem in the future, here are the reasons why the template hierarchy could be deactivated by Buddypress:
Theme compat is disabled when a theme meets one of the following criteria:
1) It declares BP support with add_theme_support( 'buddypress' )
2) It is bp-default, or a child theme of bp-default
3) A legacy template is found at members/members-loop.php. This is a
fallback check for themes that were derived from bp-default, and have
not been updated for BP 1.7+; we make the assumption that any theme in
this category will have the members-loop.php template, and so use its
presence as an indicator that theme compatibility is not required
https://buddypress.org/support/topic/default-theme-is-still-showing/

Using Jetpack Portfolio Project in WordPress child theme does not call archive custom template

I have a child theme that uses the new Jetpack Portfolio Project custom post type and wish to modify archive.php to display custom results.
I'm using: WordPress v3.9.2; Theme: Child of Point, Jetpack is installed with Custom Content Types enabled, and Portfolio Projects selected in the Settings. (No other plugins that implement portfolio functionality are installed.)
According to the Codex:
Template Files
In the same way single posts and their archives can be displayed using
the single.php and archive.php template files, respectively,
single posts of a custom post type will use single-{post_type}.php
and their archives will use archive-{post_type}.php
and if you don't have this post type archive page you can pass BLOG_URL?post_type={post_type}
where {post_type} is the $post_type argument of the
register_post_type() function.
My understanding is that if you create files called single-jetpack-portfolio.php and archive-jetpack-portfolio.php within the child theme, WordPress will automatically use those files in place of single.php and archive.php respectively.
However, my child theme successfully calls single-jetpack-portfolio.php, but completely ignores archive-jetpack-portfolio.php, instead calling archive.php in the child.
I am stuck for a solution.
From the codex above, adding to the URL "?post_type=jetpack-portfolio" does cause the child theme to correctly use archive-jetpack-portfolio.php, but should I need to be manually modifying every single URL to explicitly specify this? Should WordPress not automatically be detecting this, as it does for the single-jetpack-portfolio.php file? How can I solve this?
I have tried:
Resetting the permalinks in case it was related to that (changing the option in Settings and saving and back again)
Adding an archive.php file to the child in addition to archive-jetpack-portfolio.php (I initially didn't have an archive.php in the child, so it used the parent's archive.php)
Publishing a new Jetpack portfolio project and updating an existing page (I read somewhere that publishing something might trigger Wordpress to see the changes)
Thanks in advance for any help.
I had the same problem described by the OP. When I visited mydomain.com/portfolio it would use the custom archive template. When I tried to view a project type it defaulted to the regular archive.php. I'm wondering if OP was viewing a project type page without realizing it.
My solution was to create a taxonomy template file. After playing around with it I figured out that
taxonomy.php
taxonomy-jetpack-portfolio-type.php
taxonomy-jetpack-portfolio-type-{name-of-project-type}.php
all worked correctly, depending on how specific you wanted to get.
There's more info at the wordpress codex: http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display
Hope this helps someone.
I will be working on this the next days.
You should try this in the child archive.php first lines:
<?php
if( is_post_type_archive('jetpack-portfolio') )
get_template_part('content', 'jetpack-portfolio');
elseif( is_tax('jetpack-portfolio-type') || is_tax('jetpack-portfolio-tag') )
get_template_part('archive', 'jetpack-portfolio');
else continue;
?>

Including plugins in your wordpress theme?

I am developing a WordPress theme, i have downloaded and installed the "contact form 7" plugin. Now when i send this theme to my client and they install/activate the theme, i would like the "contact form 7" plugin to be included.
I haven't got access to their wp-admin and i can't expect them to manually install the plugins. So to make it easier for them, i'd like to package the plugins with the theme. Then they install and everything works correctly.
How do i do this or is there a better way e.g. recommend installing a plugin?
You will want to use some variant of the following:
function my_activate_theme() {
$plugins = array(
"plugin_name_1",
"plugin_name_2",
"etc..."
);
foreach ($plugins as $plugin) {
$path = '/path/to/wordpress/wp-content/plugins/{$plugin}.php';
activate_plugin($path);
}
}
add_action('switch_theme', 'my_activate_themes');
You will have to fiddle around with my code, as I don't have access to a wordpress install at the moment to test on, but basically the idea is that you throw this into your functions.php file. It registers the hook for switching theme and on theme switch, loops through the specified plugins and activates them.
I hope this helps, if not, please give me more information and I will attempt to provide further guidance. Good luck!
If you are currently developing theme, you'd rather use tgm activation code than including plugins into your theme.
Please review this Wordpress Theme.
This theme use tgm activation code to install "Visual Composer","Layerslider","Revslider","Quickshop" plugins.
It's much easier to customize and has lots of features. Also easy to learn code tips.
Regards. HanaTheme.

admin template selection is missing on page creation in wordpress 3.2.x

I am using WordPress 3.2.1 ,
Page template selection drop down is missing on Pages (Add,Edit)
wp-admin > Pages >Add New > Page Attributes
I Edit the Template Page Default page as below code
/*
Template Name: New Template
*/
But still the template drop down no visible , my older version of WordPress it display by default.
Following is the screen shot for more idea
I solved this problem solved by adding the typical following code:
/*
Template Name: Custom
*/
Don't add any spaces after Name:
It'll work if you use template name: as well.
It might help someone: check if your index.php file is in place.
If it's not there, wordpress treats the template as corrupt and it doesn't display the template selection.
This should be simple to troubleshoot. The requirements for the page template to work are straight forward:
The template needs the page title in the top of the file like you've shown (the title needs to be wrapped in a PHP tag, you probably just didn't add it with your example bu I want to make sure you havne't overlooked it):
<?php
/*
Template Name: Custom
*/
?>
The second requirement is that the file is in the root of the theme folder.
With those two requirements in place, it should work. If it isn't working you nave a few possible issues. I list a few off the top of my head:
You might need to re-install WordPress in-case a file was corrupted
during your last update.
It's possible someone has altered the WP-Admin layout using users
roles.
That's all I can thing of at the moment, let me know how it turns out.
I had the same issue. It actually turned out to be a missing style.css file within the template directory in my case.
This happens because the get_post_templates() in class-wp-theme.php first checks for errors. If it finds any then it returns an empty array (no templates are displayed).
A side effect of this is that saving a page would clear the existing template and use the page.php instead.
So in short if the errors() method of your theme returns any errors then no templates dropdown.
hope that helps someone.
Same issued, I found out that in appearance panel in your WordPress dashboard the stylesheet is missing. You shouldn't rename the style.css in your theme folder.
Not sure if this will help anyone, but we solved the problem by disabling our theme and re-enabling it again. We had some other theme folders in the theme directory that we weren't using so we deleted those out as well. good luck, it's a really random problem to solve!
yeah!template dropdown not showing because you have no template So how to solve this::---
1 create template folder in theme
2 create a template in this folder
like:-
<?php /* Template Name: Home */ echo "template"; ?>
and check-in page dropdown will be there.

Resources