M
M
MisTFoR2020-07-07 12:28:38
WordPress
MisTFoR, 2020-07-07 12:28:38

How to add pictures to the description of a product category?

Hello!
The question is this: how to add pictures to the category description? Is it even possible to insert a WordPress editor instead of a stupid text field?

https://i.imgur.com/wRm57Ax.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pychev Anatoly, 2020-07-07
@pton

Can

Replacing the editor with WYSIWYG for categories
/**
 * Заменяет стандартное поле "Описание" полем с редактором WYSIWYG
 * на странице правки категории
 *
 * @since 2.1.0
 *
 * @param object $term Current category term object.
 */
function pc_term_wysiwyg_description_field( $term ) {
  ?>
  <tr class="form-field">
    <th scope="row" valign="top"><label for="description"><?php _e('Description'); ?></label></th>
    <td>
      <?php
      $settings = array('wpautop' => true, 'media_buttons' => true, 'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description' );
      wp_editor(html_entity_decode($term->description), 'cat_description', $settings);
      ?>
      <br />
      <script>
                jQuery(window).ready(function(){
                    jQuery( jQuery('label[for=description]')[0] ).parent().parent().remove();
                    //jQuery('#description').parent().parent().remove();
                });
      </script>
      <style>#edittag{max-width:1100px;}</style>
      <span class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></span>
    </td>
  </tr>
  <?php
}
// для категорий
add_action( 'product_cat_edit_form_fields', 'pc_term_wysiwyg_description_field', 10, 2 );
// для меток
add_action( 'product_tag_edit_form_fields', 'pc_term_wysiwyg_description_field', 10, 2 );
// для любых других таксономий по аналогии.

But keep in mind that by default, html tags are not allowed in categories. To disable this, you can use the plugin
Eventually
5f044bc8b7093051754040.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question