Support

Account

Home Forums General Issues Woocommerce Product Category Link

Solving

Woocommerce Product Category Link

  • So i’m trying to create a link to a woocommerce product category. In my template i have this.

    <a href="<?php echo get_term_link( get_field( ‘featured_page_link’ ) ); ?>">this is a test link</a>

    I have added a taxonomy field for it with category (product_cat) selected. I have selected a cat on the page via the checkbox.

    However it just breaks the template at the point where the link is and ignores the rest of the page.

    I assume i am not using product category links correctly. Please help.

    Thanks

  • Please tell more about the problem.

    Which type of ACF field are you using.

    Do you use the code where the post number is already defined? May be it’ll be work (you need to add post id)

    
    the_term_link( get_field( 'featured_page_link', $post_id ) );
    
  • I made a typo. Correct use of the function

    
    get_term_link( $term, $taxonomy = '' ); // $term is the term object, ID, or slug whose link will be retrieved
    

    In this case, ‘featured_page_link’ should return an ID (integer) or object term.

  • Hi sorry for the delay the replies filtered to my junk for some reason.
    I don’t fully understand.
    So I have set up featured_page_link as a taxonomy product_cat and selected the category in the page editor. So basically all I want to do is set the link in my template to go to the woocommerce category I have selected within the admin tool.
    Thanks,
    Kev

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.