Ich hab das mal getan...

phind.com bietet mir folgende Antwort. Keine Ahnung, ob das passt. Ich verstehe nur "Bahnhof":

----------------------------------------

ANSWER | FAST MODEL
The issue with the code you provided seems to be with the is_product_category function. One possible reason why the button disappears when you add this function is that the current product is not in the specified categories. Here are some steps that may help you:

  • First, make sure that the categories you want to target are correct and exist in your WooCommerce store.
  • You may also try using the has_term function instead of is_product_category to check if the current product belongs to a specific category. Here is an example:

Show Plain Text
  1. function woo_text_link() {
  2.   global $post;
  3.   if( has_term( array( 'category1', 'category2' ), 'product_cat', $post->ID ) ) {
  4.     echo( '<a class="button-category" href="hier-der-link">Zurück zur Übersicht</a>');
  5.   }
  6. }
  7. add_action( 'woocommerce_single_product_summary', 'woo_text_link', 30 );


  • If you want to add different links for different categories, you can create an associative array with the category slug as the key and the link as the value. You can then check which category the product belongs to and display the corresponding link. Here is an example:

Show Plain Text
  1. function woo_text_link() {
  2.   global $post;
  3.   $category_links = array(
  4.     'category1' => 'https://link-for-category1.com',
  5.     'category2' => 'https://link-for-category2.com'
  6.   );
  7.   $product_categories = wp_get_post_terms( $post->ID, 'product_cat', array( 'fields' => 'slugs' ) );
  8.   foreach ( $product_categories as $category ) {
  9.     if ( array_key_exists( $category, $category_links ) ) {
  10.       echo '<a class="button-category" href="' . $category_links[ $category ] . '">Zurück zur Übersicht</a>';
  11.       break;
  12.     }
  13.   }
  14. }
  15. add_action( 'woocommerce_single_product_summary', 'woo_text_link', 30 );


----------------------------------------

Vielleicht hilft's ja...
----------
Macerer vom Dienst