How to change current category to another in wordpress
How to change current category to another in wordpress
How to change current category to another in wordpress
Found the answer myself, since WC 3.3 woocommerce_product_subcategories is deprecated and returns an empty value: Link to woocommerce docs So you have to implement your own subcategories list view. I used as hint the code found here and rebuild the categories page as it was before
You can use the woocommerce_products_will_display(). This function returns true if the current shop page is going to display products. This will be the case if your shop pages are set to display products or subcategories and products, but it will be false if the shop pages are set to display subcategories only, and the current … Read more
Get category base permalink
Please add following code $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘category__and’ => array( 2, 6 ), ‘posts_per_page’ => 1, ); $arr_posts = new WP_Query( $args ); OR $tax_query = array( relation => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, // ‘term_id’ by default, so just here as an example ‘terms’ => … Read more
Thanks @Tom J Nowell for suggesting I post this fix as an answer! So the answer I found was that Yoast, a custom permalink plugin, and permalinks category bases were conflicting with each other on my site. Here’s what I did to fix it: Make sure your category base is specified in Permalinks. Save them. … Read more
Is there a “sensible” limit to WordPress Categories?
The style-attribute is not in the span-tag, but should be. Further you are using the php opening tag inside of the echo tag (copy-paste?). change ‘<span class=”termek-oldal-kategoria-teszt”> style=”background-color:<?php the_field(‘kollekcio_szine’); ?>”‘ to ‘<span class=”termek-oldal-kategoria-teszt” style=”background-color:’.get_field(‘kollekcio_szine’) . ‘”>’ (sorry, I would have commented, but I don’t have enough reputation)
You can set post terms programmatically with wp_set_object_terms(). There’s also wp_set_post_terms() which is a wrapper for the first function, but with some extra processing of the parameters in it. foreach ( $array_of_post_ids as $post_id ) { // appends my-category to a post’s categories wp_set_object_terms( $post_id, ‘my-category’, ‘category’, true ); }
You’ll find an appropriate filter in the get_terms function which is called by get_categories. See source code https://github.com/WordPress/WordPress/blob/master/wp-includes/taxonomy.php#L1247 We don’t use any of the callback arguments in this case. We can use array_filter on the list of terms (WP_Term) objects. See https://developer.wordpress.org/reference/classes/wp_term/ This allows us to remove a term with a particular ID add_filter( ‘get_terms’, … Read more