I'm trying to customize the standard woocommerce theme and so far that has worked well. I copied all template files from /plugins/woocommerce/templates to /mytheme/woocommerce and customized the files.
But when i'm change something in archive-product.php nothing happens? I even tried to customize this in the core files (/plugins/woocommerce/templates/archive-product.php) but i doesn't work.
I want to change the class of the h1 heading: <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>.
So i looked up all woocommerce template files, the class page-title occurs only in this one file (to prevent editing the wrong file).
Edit:
In detail, i want to customize the theme used in this path: http://example.com/product-category/mycategory
I tried all the above solutions, to no avail. No matter what I did, the archive-product.php was not being used at all. Instead, most woocommerce pages were using page.php from my theme.
The solution for me was to add theme support... Which, it's been a while since I used woocommerce, so I completely forgot about that. But after adding the following line to my functions.php file, archive-product.php is now being used (/mytheme/woocommerce/archive-product.php) and I can update it, as I should be able to.
add_theme_support('woocommerce');
Seems this is STILL an issue in Woocommerce. For anyone landing here, the following solution was working for me as of version 2.1.6.
Apparently the problem is due to the function woocommerce_content() outputting the wrong page for archive content.
I used the following to get around it:
replace woocommerce_content() in woocommerce.php with:
if ( is_singular( 'product' ) ) {
woocommerce_content();
}else{
//For ANY product archive.
//Product taxonomy, product search or /shop landing
woocommerce_get_template( 'archive-product.php' );
}
Credit: found the solution here
Here's how I fixed mine:
Delete woocommerce.php in your theme folder.
Copy TEMPLATE folder in woocommerce plugin dir, paste it in your THEME folder, and rename it to woocommerce.
Open the folder you just renamed, go to shop folder, and edit wrapper-start.php and wrapper-end.php.
If you use the woocommerce.php method you cannot customize archive-product. You must use the hooks method
http://docs.woothemes.com/document/third-party-custom-theme-compatibility/
Please note: when creating woocommerce.php in your theme’s folder, you won’t be able to override the woocommerce/archive-product.php custom template as woocommerce.php has the priority over archive-product.php. This is intended to prevent display issues.
For others searching here, doublecheck the path. It is for example not /mytheme/woocommerce/templates/archive-product.php but only /mytheme/woocommerce/archive-product.php. I didn't have to apply #Talk nerdy to me's patch or any other to make it work.
you need to edit the file "taxonomy-product_cat.php" and add a conditional is_product_category( 'mycategory' ).
open your theme folder and add a new subfolder named "woocommerce" to it.
copy the files "archive-product.php" and "taxonomy-product_cat.php" from /plugins/woocommerce/templates to the woocommerce subfolder in your theme.
rename "archive-product.php" to "archive-mycategory.php" (or whatever you like, this will be the template file to the category).
open "taxonomy-product_cat.php" and wrap the wc_get_template( 'archive-product.php' ); with:
if (is_product_category( 'mycategory' )){
wc_get_template( 'archive-mycategory.php' );
} else {
wc_get_template( 'archive-product.php' );
}
Related
I've been scouring the net trying to find the solution for this problem, despite it appearing to be quite simple.
I'm, as the title suggests, trying to remove the "Category:" from the title of each category page, while keeping the actual category text there, e.g. "Category: Footwear" should read "Footwear".
Now I have tried several of the solutions on this site but to no avail. The text still appears as it always has. I am using the Astra theme on WordPress.
I'm currently using the below code, but it doesn't work, hence my asking for help.
add_filter( 'get_the_archive_title', 'so_remove_category_prefix' );
function so_remove_category_prefix( $title )
{
if ( is_product_category() )
{
$title = single_term_title( '', false );
}
return $title;
}
If anyone has any solutions, I'd appreciate the help.
Thanks!
you can overwrite the woocommerce default template in your child theme and change content or title as per your requirement
default template file is located in below folder
wp-content/plugins/woocommerce/templates
You need to create a folder named woocommerce in your theme directory. After creating folder copy the template file folder to woocommerce folder in which you are created in your theme folder
I am trying to override a woocommerce plugin but somehow it wont work.
In my custom theme I added the following in functions.php
function add_theme_wc_support() {
add_theme_support('woocommerce');
add_theme_support('woocommerce-composite-products');
}
add_action('after_setup_theme', 'add_theme_wc_support');
The directory for my template:
theme\templates\woocommerce-composite-products\single-product\template-file.php
I edited the template but nothing happened. I also tried to change the folder "woocommerce-composite-products" to just "woocommerce" but nothing.
My functions.php only contains the "add_theme_wc_support" function, so there cant be any conflicts.
How can I make this work?
Going by the comment you provided about how the plugin wants you to override the template your file path should look like this
The solution provided in the link below no longer works:
Using a custom single product template for a specific product category in Woocommerce
I have worked through the diagnositic steps adumbrated by LOIC.
I added a copy of the single-product.php file to the woocommerce folder in my child theme.
When I checked the Woo status page it confirms that that page is overwriting the woo template.
I created a new product and assigned it the category: Custom (with the slug: custom).
I placed the following code in my functions.php:
add_filter( 'template_include', 'custom_single_product_template_include', 50, 1 );
function custom_single_product_template_include( $template ) {
if ( is_singular('product') && (has_term( 'custom', 'product_cat')) ) {
$template = get_stylesheet_directory() . '/woocommerce/single-product-custom.php';
}
return $template;
}
I edited out the hooks from a copy of the single-product.php and renamed it: single-product-custom.php and put it in the woocommerce folder in my child theme.
Cleared all site caching and my browser history.
However, the test product is still displaying the default single product page.
Where I am going wrong and where do I go from here?
Problem resolved. Note: if you are seeking to use this solution there a couple of posts here with conflicting information. The solution above does work. The file to be placed in your theme folder is single-product woo template (with your custom title) not the content-single-product template as suggested in some other posts on this subject.
Also take care to note Loic's advice: If you are using a child theme. You create a woocommerce folder in your CT and then place the copy file in there. Do not place it inside a templates subfolder (as is the case in the Woo Plugin file structure).
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;
?>
I want to overwrite the file plugins/the-events-calendar/tickets/meta-box.php of the plugin The Events Calendar.
I followed the tutorial Overwrite Plugin Files but this is not working for me.
How can I overwrite this file?
i want to add new metabox in evetns Ticket section how can i do without edit the plugin file other wise overwrite that plugin files.
I don't have the paid Ticket plugin you refer to, but I took a bit of time to skim through the available GitHub code:
https://github.com/moderntribe/the-events-calendar/
It looks like the overwrite option (i.e. moving a file from the plugin folder to the tribe-events/ folder within your current theme directory) only applies to the views templates in:
https://github.com/moderntribe/the-events-calendar/tree/master/views
You can see for example the definition of the getTemplateHierarchy() function here.
But this overwrite option doesn't apply to the /admin-views/tickets/meta-box.php file, since it's included here with the default PHP include():
include $this->path . 'admin-views/tickets/meta-box.php';
through this method call here:
TribeEventsTicketsPro::instance()->do_meta_box( $post_id );
where the metabox comes from:
add_action( 'add_meta_boxes',
array( 'TribeEventsTicketsMetabox', 'maybe_add_meta_box' ) );
Looking at the source of this file, I found this part:
<?php do_action( 'tribe_events_tickets_metabox_advanced',
get_the_ID(), NULL ); ?>
This might be what you are looking for, if you want to add some extra tickets UI to the event editor. Try to hook into this tribe_events_tickets_metabox_advanced action to add your extra UI.
Hope this help.