How to add custom fields to $ filters[] (urgent)
-
Hello everybody!
$filters[] = 'woocommerce_short_description';
I just do not know how to work with my fields. I’ve tried everything I could think, but nothing works.
Below are some of my fields:
functions.php
// Display Fields add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); // Save Fields add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' ); function woo_add_custom_general_fields() { global $woocommerce, $post; echo '<div class="options_group">'; // Select woocommerce_wp_select( array( 'id' => '_product_type', 'label' => __( 'Product type', 'woocommerce' ), 'options' => array( 'Doujinshi' => __( 'Doujinshi', 'woocommerce' ), 'Manga' => __( 'Manga', 'woocommerce' ), 'Novel' => __( 'Novel', 'woocommerce' ), ) ) ); woocommerce_wp_select( array( 'id' => '_product_condition', 'label' => __( 'Product condition', 'woocommerce' ), 'options' => array( 'Used' => __( 'Used', 'woocommerce' ), 'New' => __( 'New', 'woocommerce' ), ) ) ); echo '</div>'; } function woo_add_custom_general_fields_save( $post_id ){ // Select product type $woocommerce_select = $_POST['_product_type']; if( !empty( $woocommerce_select ) ) update_post_meta( $post_id, '_product_type', esc_attr( $woocommerce_select ) ); else update_post_meta( $post_id, '_product_type', '' ); // Select product condiction $woocommerce_select = $_POST['_product_condition']; if( !empty( $woocommerce_select ) ) update_post_meta( $post_id, '_product_condition', esc_attr( $woocommerce_select ) ); else update_post_meta( $post_id, '_product_condition', '' ); }
short-description.php
<?php $product_type = get_post_meta($post->ID, '_product_type', true); if( !empty( $product_type ) ){ echo '<b>? Product type: </b>'.$product_type.'<br />'; } ?> <?php $product_condition = get_post_meta($post->ID, '_product_condition', true); if( !empty( $product_condition ) ){ echo '<b>? Product condition: </b>'.$product_condition.'<br />'; } ?>
And I would like to add them to:
add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' ); function more_text_replacements( $filters ) { $filters[] = 'the_meta'; // Here you could put in the name of any filter you want return $filters; }
I hope someone can help me! Any help is welcome! Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add custom fields to $ filters[] (urgent)’ is closed to new replies.