M
M
Maxim Gerasimenko2019-02-10 17:32:51
PHP
Maxim Gerasimenko, 2019-02-10 17:32:51

How to remove submenus in WordPress?

I am making a menu in the site header. An example is here . The site will be on the latest version of WordPress.
I'm using the twentynineteen theme.
The problem is that menu items that do not fit in length are removed under a special button.
5c60357de50a3566787253.png
How can I disable this button. And the menu items lined up in length. There are enough places.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel, 2016-07-29
@Olivoin

In order not to receive such errors, you need to check whether the $subheadingvalues ​​variable is empty. But it is so. In general, everything is written in the plugin itself. Attributes are displayed in the product in the "additional information" tab, let's see the code of this tab. plugins/woocommerce/templates/single-product/tabs/additional-information.php
The code there is <?php $product->list_attributes(); ?>using the list_attributes() method; You can stop there and write in your template

global $product;
$product->list_attributes();

But we get the finished markup in the form of a table. Let's see what the list_attributes() function does;
public function list_attributes() {
    wc_get_template( 'single-product/product-attributes.php', array(
      'product'    => $this
    ) );
  }

We go to the folder for the desired file plugins/woocommerce/templates/single-product/product-attributes.php
Among other things, we see in it
$attributes = $product->get_attributes();
.........
<?php foreach ( $attributes as $attribute ) :
    if ( empty( $attribute['is_visible'] ) || ( $attribute['is_taxonomy'] && ! taxonomy_exists( $attribute['name'] ) ) ) {
      continue;
    } else {
      $has_row = true;
    }
    ?>
    <tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
      <th><?php echo wc_attribute_label( $attribute['name'] ); ?></th>
      <td><?php
        if ( $attribute['is_taxonomy'] ) {

          $values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
          echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );

        } else {

          // Convert pipes to commas and display values
          $values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
          echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );

        }
      ?></td>
    </tr>
  <?php endforeach; ?>

Adapt to your needs. I think it should work)
PS Don't forget to look at the documentation. Here is a complete list of what can be done with $product https://docs.woocommerce.com/wc-apidocs/class-WC_P...

V
Vadim, 2017-09-18
@TornMen

Hello, how can I display text for a specific product by attribute.? For example, if a certain attribute is assigned to a product, the text is displayed, if not, then there is no text. ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question