I have set 2 custom fields on the wordpress / woocommerce product page called "imballo" and "sottoimballo" with their values. How do I display these on the published page?
Thanks!
You would have to display the custom fields in the WooCommerce Single Product Page template,
You could do it in two ways,
Add a code in an existing hook of the Product Single page. Check hooks here
Modify the template by overriding it in your WordPress theme. Read here
And in the place where you want to display do the following,
<?php
//Please add your HTML structure as needed.
echo get_post_meta(get_the_ID(), 'imballo');
echo get_post_meta(get_the_ID(), 'sottoimballo');
?>
Related
I am using this shortcode [products limit="4"] to show the products on a different page called Theme.
Now I want to change the layout style of this Theme page by overriding woocommerce template file.
1) Which template file woocommerce is calling for this shortcode?
2) Can you give me a full reference where I can find which template file is responsive for which shortcode?
Regards.
Every shortcode related to product listing is calling template named content-product.php via follows -
// Render product template.
wc_get_template_part( 'content', 'product' );
You can find it here
I wanted to create a page template that is the same design as the woocommerce (please refer to the image below) product category template and display by category in my custom page template. How will start I am a newbie in woocommerce.
default product category template design
First create the page template in your theme's folder. Kindly check following steps.
1) Add mynewtemplate.php in your theme's folder.
2) Add <?php /* Template Name: My new template*/ ?> in newly created file. refer http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/ for more info.
3) At admin side add new page and choose My new template template.
4) You can add following codes in page editor.
There are list of short-codes are available.
[woocommerce_product_filter] — shows a live Product Search Filter.
[woocommerce_product_filter_attribute] — shows a live Product Attribute Filter.
[woocommerce_product_filter_category] — shows a live Product Category Filter.
[woocommerce_product_filter_price] — shows a live Product Price Filter.
[woocommerce_product_filter_tag] — shows a live Product Tag Filter.
[product_category category="shirt"] - Displayed `shirt` category product
https://docs.woocommerce.com/document/woocommerce-product-search/shortcodes/ check for more info.
5) If you don't want to add this in page content area then add your code in mynewtemplate.php
<?php
do_shortcode( '[woocommerce_product_filter]' ); //— shows a live Product Search Filter.
do_shortcode( '[woocommerce_product_filter_attribute]' ); //— shows a live Product Attribute Filter.
do_shortcode( '[woocommerce_product_filter_category]' ); //— shows a live Product Category Filter.
do_shortcode( '[woocommerce_product_filter_price]' ); //— shows a live Product Price Filter.
do_shortcode( '[woocommerce_product_filter_tag]' ); //— shows a live Product Tag Filter.
do_shortcode( '[product_category category="shirt"]' ); // - Displayed `shirt` category product
?>
Hope this will help you.
I'm working on a WordPress website and i have a little problem with the custom fields plugin. I'm familiar with plugin and worked with it few times before.
I created a custom field for posts and a custom field for pages.
When i try to get the page's custom field i get it with no problem.
The page has global $post on top and i do get a different $post->ID
for each post loaded.
$pageMonth = get_field('page-month');
But when i try to get the post's field i get nothing.. I also tried it through
the post's loop with $post->ID
<?php $postMonth = get_field('post-month', $post->ID); ?>
I checked myself few times, the custom field names are fine and i did
attached the post and the page to their custom fields and everything..
I would like my product page that customers fill 5 text fields and choose 1 field type radio.
So my product page is a form where customers ask a question, fill some information and choose a paid option.
Like this french page => http://www.avocat-bervard.com/paiement-honoraires-consultation-juridique/
Is it possible with Woocommerce ?
If so, can you explain me how ?
Thanks.
You can create nice forms with plugin Ninja Forms :). Its a very cool plugin, with a couple of settings: sending emails, when submitting forms, etc.
It is also supports shortcodes, with this method you can implement your form on every single product page, or even display it in a widget area.
For widget area:
You need to enable shortcodes first in functions.php
add_filter('widget_text', 'do_shortcode');
Then call the shortcode in Appearence - Widgets
For template:
You need to edit the file where you want this form to display, single-product.php, meta.php :) etc.
To insert shortcode in template file you need to use the below code:
<?php echo do_shortcode( $content ) ?>
I'm using the plugin Advanced Custom Fields on a custom post type. When I enter in content into the custom fields and publish, all looks fine BUT when trying to search for words that are in a custom field it doesn't show up...
I really need this content to be searchable.
I'm displaying the custom fields using this code
<?php echo get_post_meta($post->ID, 'course-code', true); ?>
Can anyone help please.
Post meta is not included in WordPress default search. You could use a plugin like Relevanssi, which extends WP's search functionality.