Viewing 9 replies - 1 through 9 (of 9 total)
  • I’m having the same issue. vfreefly did you by chance find a solution?

    I know you can click and drag to reorder the categories in the category editor, but that only seems to change the display in the dashboard on the edit product page rather than control the priority of which categories take precedence over others. I’ve noticed a lot of other people are asking questions about this as well, it would be really useful to be able to set which categories take priority over others!

    Digging out an old thread… Did anyone find a solution to this?

    I don’t know how many times I sighed at the sight of these URLs…

    WooCommerce uses the category with the lowest ID (oldest creation date) as the primary URL. If someone could come up with a way to determine a product category priority so that WooCommerce would use that list instead of the ID-sorted one, that would be quite amazing.

    This would be an interesting challenge that I’d quite willingly take if I had more time on hand hehe.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Thank you infinitely for this link Mike!

    Looks like this will be pretty straightforward from here, good to know this filter exists.

    Just to make sure because I’m not very used to filters yet…

    The custom function in our child-theme functions.php will look like this :

    function my_custom_product_category_list($terms_array, $terms, $post) {
    // Do stuff
    return $product_category;
    }
    add_filter {'wc_product_post_type_link_product_cat', 'my_custom_product_category_list', 10, 3 }

    Is that correct so far?

    Thank you!

    Kind regards,
    B

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Brackets are wrong in add_filter but along the same lines.

    You’re right, wrote that too fast ??

    Thank you again!

    Just ran across this thread because I was having the exact same problem. I can see that the filter is supposed to change the category, but having a hard time visualizing it. In the example function posted, what would go in the // Do stuff section?

    Hey Bottlenosenomad,

    Let me suggest that you use Yoast SEO, it allows you to pick the main category from the product editing page in a very, very user-friendly manner.

    Cheers!

    Regards,
    Bastien

    Thanks, Bastien! I’ll give that a shot.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Category priority for product url in WooCommerce’ is closed to new replies.