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
Related
What i want is to edit a subscription in my account page of woocommerce. i have shared a picture below, of what exactly I want to edit.
This is the link of picture, what i want to edit is highlighted with red pen:
I want to edit the things which are highlighted with red pen. but i am unable to locate the exact page of this where i can edit things.
actually i want to change the link of update button in subscription table.
the URL of the page is like :
https://www.example.com/my-account/subscriptions/
There is no subscription page in pages menu of wordpress.
I am also unable to see this in endpoint of woocommerce.
Is there any way to do it ?
First have a look to that: Template structure & Overriding templates via a theme… It explains how to override correctly woocommerce templates via your active theme.
The templates that you will override have to be located in woocommerce folder inside your theme folder…
Now in the woocommerce-subscriptions plugin folder, you have also a template folder, and you can pick the necessary templates that you need to change, copying them into that woocommerce folder located in your theme, taking care to keep path (subfolder hierarchy)…
So you will copy from: wp-content/plugins/woocommerce-subscriptions/templates/myaccount(5 files inside)… to wp-content/themes/your-theme/woocommerce/myaccount (where your-theme is the folder name of your theme)…
Now you can edit templates just like the woocommerce ones…
The subscription end point is not listed in woocommerce as it's not a default end point
To rename the menu label for "Subscriptions", you can use this:
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_menu_items', 0, 15 );
function rename_my_account_menu_items( $items ) {
// HERE set your new label name for subscriptions
$items['subscriptions'] = __( 'Custom label', 'woocommerce' );
return $items;
}
The code goes on function.php file of your active child theme (or theme) or in any plugin file.
Tested and working
I'm working with WooCommerce including the WooCommerzce Germanized Plugin.
The Plugin changes a lot of WooCommerce to make it safe for usage in Germany.
Now I need to modify a template file of the plugin. Whats the best way to make the changes? I don't want to modify the template itself to keep it safe for updates.
In order to override any WooCommerce plugin template you should create a folder in your active theme named after the plugin you are going to modify. Then follow the template folders structure ignoring just the folder templates and copy the desired file there.
For example, I needed to modify the WooCommerce Germanized Pro template based in /plugins/woocommerce-germanized-pro/templates/checkout/multistep/data.php. To modify it I have copied it to my theme: /themename/woocommerce-germanized-pro/checkout/multistep/data.php -- this way it will override an original template file.
Good luck!
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
I'm using the 3.9.3 version of Avada and the 2.5.5 version of WooCommerce.
How can I edit the fields that are in the checkout page?
I want to auto compile the email field with a saved cookie and make the email input readonly.
Is it possible? What files I need to edit?
Thanks.
You can do that in woocommerce templates (and also with some hooks).
For templates files, they are located in your woocommerce folder. You have to copy this templates directory inside your active theme (or child theme) and rename it woocommerce (if don't exist yet).
Inside the new directory woocommerce located in your active theme, go to checkout subfolder and you will find related php files, that you can edit to fit your needs.
After that if you need a specific hook, you can search in here (or post a related question, if it doesn't exist yet). Here you can fin an example of hook…
I have a created a view (lets call it my_view).
In the theme: information section if the view I have noted one of the suggested template names (views-view--my-view--default.tpl.php (or close to that)), and created my own template file with that name.
This all works fine and when I visit the theme registry, I can see there is a hook there with the name of the template (views-view--my-view--default). However this hook has a type field of 'engine' rather than 'module'. I assume this is to do view the way views works out its own theming?
I want to implement hook_registry_alter to modify this theme hook (and others created in the same way), but I cant work out how to retrieve a list of these hooks.
I tried using array_keys(views_theme()) to get all the views hooks back but this list doesn't contain hooks created by over-riding template files. It only contains the default hooks like views_views_field etc
Is there a way to bring back a list of views theme hooks over-ridden in this way?
I answer here as your last comment seems to indicate you are not interested anymore in pursuing your initial approach, and 600 chars would not be enough, anyhow.
An alternative approach to achieve what you want could be to use the "inheritance" of sub-themes from their parent theme. You could in other words define your user theme as a sub-theme of the admin theme.
In this way the theming engine would search for templates - in the case of a user viewing the site through the user theme - first in the user theme folder, then in the admin theme folder, and then in the module directory.
This is for example the same mechanism used by zen for letting you create your themes with the starter kit.
Hope this helps!