Use default WooCommerce Gallery - php

My WooCommerce theme has a custom gallery that is coded directly into single-product.php. Rather than using this custom gallery, I wish to display images on the product screen with the original default Woo Commerce gallery.
The files in the plugin that I believe display the default gallery are:
product-image.php
product-thumbnails.php
I'm new to server side programming and PHP. I've tried the following code:
<?php wc_get_template_part( 'content', 'product-images' ); ?>
<?php wc_get_template_part( 'content', 'product-thumbnails' ); ?>
But this doesn't return anything.
How do revert to the original WooCommerce gallery when my theme has an image gallery hard coded into single.php?

In your case it seems that your theme has custom woocommerce templates files inside it. The trick could be trying replace some of those templates files, by the original ones. The better way to do that is to set a child theme, avoiding theme updates problems…
1) If you are using a child theme:
Copy the woocommerce folder located in your parent theme to your child theme.
Replace from the woocommerce plugin, templates folder, the needed templates files to the woocommerce folder inside your active child theme.
2) If you are not using a child theme, Just replace from the woocommerce plugin, templates folder, the needed templates files to the woocommerce folder inside your active theme.
Reference: Overriding Templates via a Theme

Related

create CMS for wordpress theme

I have converted HTML site to WordPress theme and uploaded it to the server, now i want to create CMS for this theme , but there are another active theme now and those are the the current pages.
how can I create a new page for my new converted theme without losing or effecting the current themes and the contents?
this the themes the active theme and my new covered theme
From what you describe I would advise you to create a Child Theme: https://developer.wordpress.org/themes/advanced-topics/child-themes/
Then you will be able to overrides only the templates you want if you conform to WordPress' Template Hierarchy: https://developer.wordpress.org/themes/basics/template-hierarchy/

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.

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

Overriding specific third party Woocommerce plugin templates

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

Wordpress about a tutorial

I want to know something about this article
In order to create custom post types, open your template’s
functions.php file in an editor, and
place the following function within
the file:
Where is this file function.php in wordpress 3.0.3
You must open the file functions.php that is in your template directory, in /wp-content/themes/your-theme-name.
If the file is not present, create it.
It is /wp-content/themes/[name-of-theme]/functions.php
e.g if twentyten (default theme)
/wp-content/themes/twentyten/functions.php
Custom post types and custom taxonomies should be added through a plugin, and not through a theme. It is the recommended way to add these.
Just a couple of reasons why you should add custom post types and taxonomies via a plugin
custom post types and custom taxonomies add functionality to your site, and not your theme. They also do not add visual benefit to your theme
custom post types and custom taxonomies should remain available across themes. If a theme is changed, these should still be available to the next theme activated

Categories