简体   繁体   中英

Woocommerce: Change Category word in single product page


I'm designing a new WordPress website using Woocommerce. After I complete the website the client asked me to change JUST A WORD in the single product page, I tried a little but I'm afraid to ruin everything. so please if any one can help me changing the word CATEGORY to BRAND from the theme files. you can check the product on the following link:
http://kode.blissgraphic.com/product/aor001o/ Thanks

thank god found your solution

Are you using the most current version of WooCommerce? If so, look in your plugins folder and navigate to "woocommerce -> templates -> single-product -> meta.php". Look on line 27 and you should see at least one location where this is being created. Try to edit that line and see if it works for you.

Keep in mind, anytime you are editing the WooCommerce template files you should move them into your theme folder. This way you will still be able to update WooCommerce without overwriting your edits. You can edit these files in an upgrade safe way through overrides. Simply copy it into a directory within your theme named /woocommerce, keeping the same file structure except you don't include the templates folder. So to override the meta.php file the structure inside of theme folder would be: woocommerce -> single-product -> meta.php

taken refrence from How to edit what's displayed in the Woocommerce Single Product Meta template?

tried in my own wordpress site as well

in meta.php on line no 35 replace this

<?php echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Brand:', 'Brands:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>

It worked for me!! cheers

You can remove these from the layout by removing the woocommerce_template_single_meta action from the product summary , in your themes functions.php add in …

 remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

This will remove the categories aka product meta from the layout.

You can see a lot of these woocommerce hooks in the plugin woocommerce/includes/wc-template-hooks.php – our example above is originally is in this file highlighted.

/**
 * Product Summary Box
 *
 * @see woocommerce_template_single_title()
 * @see woocommerce_template_single_price()
 * @see woocommerce_template_single_excerpt()
 * @see woocommerce_template_single_meta()
 * @see woocommerce_template_single_sharing()
 */
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );

So the action includes the hook and what function we are hooking into it and the priority number – so instead of editing here, you just simply remove_action the desired action in your functions.php including the priority number, the trick is finding out which one you need!

You wan't to customise the word "Categories:", then, If you are using Storefront, or any other decent "extendable" theme, from the child-theme you can 'override' the template-function that renders the meta in single-product by just pasting the code of the function in your theme's function.php file.

You can read more about this in this post:

Override a Wordpress parent theme function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM