woocommerce get product category id

Dmitri Jurovski

I have problem, this very simple question but very important fore me. Thanks fore reading! My Problem: I'm create presentation page with different category. Each presentation blog have title, description, thumbnail and litel custom menu widget where sub category. My page Cases&Bag have section Bags information about Bag, title, description and have custom menu widget where link category Women-Bags and Men-Bags. But under this section i need custom buttom with link to just category all Bags. And need put Buttom

      href="====> Problem heare ( link product category by or or slug ) <===" class="btn btn-default btn-lg manage-btn " role="button">SHOW ALL BAGS</a> 

     Imagen  category-> Cases&Bag/Bags/Women-Bags
        category-> Cases&Bag/Bags/Men-Bags

My code now lock like this:

    <?php // Get the ID of a given category
//$category_id = get_cat_ID( '62' );
// Get the URL of this category
$category_link = get_category_link( 62 );
?>
<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-default btn-lg manage-btn " role="button" title="SHOW ALL BAGS">SHOW ALL BAGS</a>

This not work. It norla? or i have some problem in system?

Bilal Hussain

try this

 <?php
    // Get the ID of a given category
    $category_id = get_cat_ID( 'SHOW ALL BAGS' );


    // Get the URL of this category
    $category_link = get_category_link( $category_id );

?>

<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-default btn-lg manage-btn " role="button" title="SHOW ALL BAGS">SHOW ALL BAGS</a>

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Get top level parent product category as body class in WooCommerce

How to get product category ids from order items in WooCommerce

Get a list of siblings term ids from current product category in WooCommerce

Woocommerce Get Product Values by ID

Get a specific product by id in WooCommerce

Get "primary" category image from WooCommerce product

Get the product category name and description in Woocommerce Single Product page

Get the parent product categories ids from a sub product category ID in Woocommerce

Get all Woocommerce products from current product category term Id in a WP_Query

Get specific product attribute values for a specific product category in Woocommerce

Get Woocommerce product category image url

Check a product category for a product in Woocommerce

WooCommerce: Get purchased items for a product category using a SQL query

Get the subcategories of the current product category in Woocommerce archives

Get the category name from a WooCommerce product using the product id or the category id

Get also WooCommerce product category thumbnail Id using a SQL query

Woocommerce: Product Category Widget

Get only one product category term for a WooCommerce product

Woocommerce get Product id using product SKU

WooCommerce: function that returns all product ID's in a particular category

WooCommerce get product attributes with given product ID

Woocommerce - get product in category with specific attribute

Getting the 'thumbnail ID' from last product category term in WooCommerce

Get on sale products for Woocommerce product category archives using a Get request

Get and display the product category featured image in Woocommerce

Is there a way to get all the category slug of a woocommerce product

Woocommerce, get main product id

WooCommerce database query : Get product category image path+name from thumbnail_id

How can I get product price, image and perm link by category id woocommerce