Overriding specific third party Woocommerce plugin templates - php

I'm using a Woocommerce based plugin called Mix 'n Match Products.
This plugin sits inside /plugins/woocommerce-mix-and-match-products/
This folder contains another folder for templates.
Following convention, I have copied the "templates" folder into my child theme and changed the folder name to "woocommerce-mix-and-match-products"
The structure is now themes/storevilla-child/woocommerce-mix-and-match-products/
However, none of the templates override the plugin templates. I have tested. Only once I change the actual plugin template files, does the HTML change.
Can anybody spot what I may be doing wrong?
Thanks

The way to do it is a little bit different. All WooThemes woocommerce plugins use the default woocommerce templates folder described in this documentation:
2 cases:
You have already a woocommerce folder in your active child theme (or theme).
Copy from plugins/woocommerce-mix-and-match-products/templates/single-product/mnm/
to themes/your_active_theme/woocommerce/single-product/
And plugins/woocommerce-mix-and-match-products/templates/single-product/add-to-cart/mnm.php
inside themes/your_active_theme/woocommerce/single-product/add-to-cart/
You don't have any woocommerce folder in your active child theme (or theme).
Copy from plugins/woocommerce-mix-and-match-products/templates/
inside your active child theme (or theme) and rename it woocommerce.
So in your case you will have: themes/storevilla-child/woocommerce/
Reference: WooCommerce Template Structure + Overriding Templates via a Theme

Related

WordPress - using Ultimate Member plugin in your custom theme

I'm trying to use Ultimate Member plugin in my custom theme which I created from scratch. Well actually I downloaded this theme (freelancer) from startbootstrap.com and used it as a basis. I activated the UM plugin and added the default pages, but I'm not able to view those pages in my custom theme. Do you need to add any pages or functions in order to activate the UM plugin in a custom theme?
The plugin does work on default themes like twentynineteen. So I believe I should be missing something in my custom theme.
Here is the directory structure of my theme:
wordpress
wp-content
plugins
ultimate-member
themes
mytheme
assets //copied from bootstrap theme
author.php
css
style.css
footer.php
functions.php
header.php
index.php
js //copied from bootstrap theme
page-authors.php
page-{category-posts).php
single-post.php
style.css
ultimate-member
login-to-view
...
(and other files based on the article below)
I referred to this official article for template structure under /themes/mytheme/ultimate-member/ :
https://docs.ultimatemember.com/article/1516-templates-map
I was able to move forward when I added a singular.php file. I made additional changes on top of that but this file seemed to be the file I was missing.

How do I use the template of a theme that isn't my parent theme

I've made a child theme based on Theme A (Parent Theme). However, the search template of that theme isn't all that great. But the search template (only that template)of Theme B is awesome.
What do I have to do (in terms of coding), so my search results are based on Theme B Search Template?
I'm afraid there is no easy way you can do it.The only option you have is to look in theme B code and find everything related to search. Then try to understand it and copy it or replicate it in theme A.Unfortunately WordPress has no real standard on how a theme should be templeted, so different themes can have as many files as they would like and/or need to; the same goes for naming conventions for template parts and features.

WordPress Child Theme - General Understanding

I am trying to understand how to use a Child Theme in wordpress.
I am afraid that something will go wrong in the process of developpment because I haven't completely understood how to use the child theme or its integration wasn't done properly.
My confusion comes after I create the child theme and by adding the style.css and functions.php.
At this point, can I make any changes that I want to the child theme and it will still work?
For example,
After I modify the front-end of the website with the use of the child theme, I want to add some forms that will insert data into the database.
Do I have to implement any php files from the parent-theme in order to make this work ?
Or do I treat my child-theme as a fresh theme (blank canvas) and code the back-end however I would like ?
Thanks
Think of the child theme as a layer on top of the parent theme. By default (if you add nothing to the child theme other than a style.css file), all the templates from the parent theme will be used. The only thing you have to have is the style.css file. If you wanted to override the page.php template for instance, you would simply just make a page.php file in your child directory and WordPress will use that template instead of the parent template. Same goes for any template file or template part.
You can have a functions.php file in your child theme and it will be included in addition to the parent functions file.
Usually the parent's style.css file would be enqueued before the child's style.css file, but it depends on how those files get enqueued. The system is quite flexible.
Your child theme is not a blank canvas. It inherits style.css, functions.php and all the post/page templates from the parent theme. The style.css file of your child theme will load after that of the parent theme, thus enabling you to add more CSS rules. The functions.php file of your child theme will load before the parent's functions.php file.
The child also inherits all the templates from the parent. However, if a template exists in the parent and you create it in the child the child theme's template will completely override the parent's template. For more information on parent-child theme relationship I highly recommend that you check the official child themes documentation.

WooThemes Projects plugin - Change the location of a displayed costum field

I am using Woocommerce Projects plugin for WooCommerce and I have made some extra meta fields for the Projects.
But how can I display them on the place where I want them?
On this example page they show an option that will show it under the short description. But how can I change the location, to put it everywhere I want in the template file.
Update (see below: Overriding Projects template files safely)
What you are looking at, is this documentation, that lists all possible hooks with WooCommerce "Projects" plugin.
So you will have just change the hook in:
add_action( 'projects_after_loop_item', 'display_new_projects_fields', 10 );
Replacing 'projects_after_loop_item' by one of the hooks below to change the displayed location around the loop (for example):
projects_before_loop
projects_before_loop_item
projects_loop_item
projects_after_loop_item
projects_after_loop
Or also (with the other "Projects" plugin templates):
## General layout
projects_before_main_content
projects_after_main_content
projects_sidebar
## Archives
projects_archive_description
## Single Projects
projects_before_single_project
projects_before_single_project_summary
projects_single_project_summary
projects_after_single_project_summary
projects_after_single_project
Overriding Projects template files safely
Copy the templates directory located in projects-by-woothemes plugin folder to your active child theme directory (or active theme directory) and rename it projects.
Projects plugin will always check your theme for these files before displaying core templates as a fallback. Any template files found in the theme will be given priority and the core counterpart ignored.
Now you can edit any template file as you want, adding inside it this little peace of code (from the example), directly just where you want, displaying your custom field value, just using:
echo esc_attr( get_post_meta( $post->ID, '_location', true ) );
At the end, is better to keep in that folder, only the customized templates.
Reference and related:
Editing Projects Templates Safely
Overriding Templates via a Theme

Using WP Child Theme to override a PHP file within sub directories of main WP theme

Here is the file hierarchy:
Main Theme>PageBuilder>Blocks>campaigns-block.php
I edited the campaigns-block.php to suit my needs & now want to place it in my Child Theme to override. The Main Theme's campaigns-block.php file.
How might I do this?
Unfortunately, in the child theme you can only automatically override parts of the Template Heirarchy (header.php, page.php, etc.) You would need to override the template file that includes campaigns-block.php and direct it to your copy in the child theme folder.
See this answer for more details:
https://wordpress.stackexchange.com/questions/62341/override-file-in-parent-theme

Categories