Title: This plugin breaks the wp_get_post_terms function
Last modified: March 22, 2022

---

# This plugin breaks the wp_get_post_terms function

 *  [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * (@oscargare)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/this-plugin-breaks-the-wp_get_post_terms-function/)
 * The plugin breaks the `wp_get_post_terms` function.
 * if you try to use
    `wp_get_post_terms( $product_id, 'product_cat', array('fields'
   => 'ids' ) );` the function does not return any value if the plugin is active
   and the option _Hide Category_ is enabled.
 * Please fix it!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * (@oscargare)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/this-plugin-breaks-the-wp_get_post_terms-function/#post-15491029)
 * Hi,
 * change the category_hide_hcps function by the following code to solve the problem:
 *     ```
       public function category_hide_hcps( $terms, $taxonomies, $args ) : array {
       			$new_terms     = $terms;
       			$hide_category = get_option( 'hcps_data' );
       			if ( ! empty( $hide_category['category'] ) ) {
       				if ( in_array( 'product_cat', $taxonomies, true ) && !is_admin() && empty( $args['class'] ) ) {
       					foreach ( $terms as $key => $term ) {
       						if ( ! empty( $term->term_id ) ) {
       							if ( in_array( $term->term_id, $hide_category['category'], true ) ) {
       								unset( $new_terms[ $key ] );
       							}
       						}
       					}
       				}
       			}
       			return $new_terms;
       		}
       ```
   
    -  This reply was modified 4 years, 2 months ago by [Oscar Gare](https://wordpress.org/support/users/oscargare/).

Viewing 1 replies (of 1 total)

The topic ‘This plugin breaks the wp_get_post_terms function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/hide-categories-or-products-on-shop-
   page_6fcff7.svg)
 * [Hide Categories Or Products On Shop Page](https://wordpress.org/plugins/hide-categories-or-products-on-shop-page/)
 * [Support Threads](https://wordpress.org/support/plugin/hide-categories-or-products-on-shop-page/)
 * [Active Topics](https://wordpress.org/support/plugin/hide-categories-or-products-on-shop-page/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hide-categories-or-products-on-shop-page/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hide-categories-or-products-on-shop-page/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/this-plugin-breaks-the-wp_get_post_terms-function/#post-15491029)
 * Status: not resolved