Get only one product category woocommerce

Before I begin, just one note, there is no property called $all in get_the_terms. Here are the available fields which you can use stdClass Object ( [term_id] => [name] => [slug] => [term_group] => [term_order] => [term_taxonomy_id] => [taxonomy] => Get only one product category woocommerce => [parent] => [count] => [object_id] => ) I’m … Read more

has_term not working

You mention in a previous comment that you are defining $post directly before the conditional statements. Since this is the case you need to pass the $post object to both these functions to get desired results otherwise WordPress will attempt to use the global $post object which isn’t what you’ve defined and thus throwing errors … Read more

How to get category image custom post type taxonomy in wordpress?

From the details page of the WPCustom Category Image Plug-in : https://wordpress.org/support/plugin/wpcustom-category-image 1st – Go to Wp-Admin -> Posts(or post type) -> Categories (or taxonomy) to see Custom Category Image options. 2nd …depending on whether you want to show a single category image or display several in a loop – //SINGLE echo do_shortcode(‘[wp_custom_image_category onlysrc=”https://wordpress.org/plugins/wpcustom-category-image/false” size=”full” … Read more

How do I provide a “show all posts” link in a paginated term archive?

This method will set it up so that if you add /all to the end of your taxonomy archives, it will show all posts. First, when registering the taxonomy, make sure you set the ep_mask to EP_CATEGORIES. This means we can add a custom endpoint to it. function wpse_277843_register_taxonomy() { register_taxonomy( ‘game_go_series’, ‘game_go’, array( ‘rewrite’ … Read more

WPML Translating a term/taxonomy programmatically

Ok I found the solution. Actually taxonomy name on icl_translation table is stored with prefix called “tax_” which means taxonomy. The above code would work like this: $trid = $sitepress->get_element_trid($englist_term_id, “tax_taxonomy_name”); $sitepress->set_element_language_details($new_term_id, “tax_taxonomy_name”, $trid, $lang_code, $sitepress->get_default_language()); The difference is tax_ prefix. Cheers!

Problems with function on function.php

Did you try to use add_action without priority? On the last line, you specify the priority. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. function test_1234567() { // Get term by name ”news” in Categories taxonomy. $category = … Read more

Append a term to WooCommerce product existing product category terms

You just need to add a missing boolean argument in wp_set_object_terms() function like: wp_set_object_terms($post->ID, $term->term_id, ‘product_cat’, true); This time the term will be appended and not replaced. You should check that the term doesn’t exist yet on the product, before appending it like: add_action( ‘transition_post_status’, ‘new_product_add’, 10, 3 ); function new_product_add( $new_status, $old_status, $post ) … Read more