-1

是否有可能获得普通文本而不是使用 slug?我需要将此自定义代码用于 Wordpress WooCommerce 产品页面。输出的小问题是小写字母和单词之间的行“-”。

<?php /*CUSTOM MID*/ else: ?>


                <td class="value">
                    <select id="<?php echo esc_attr( sanitize_title($name) ); ?>" 
                            name="attribute_<?php echo sanitize_title($name); ?>">
                    <option value="">
                        <?php echo __('Choose an option', 'woocommerce') ?>&hellip;
                    </option>

                    <?php
                        if ( is_array( $options ) ) {

                            if ( empty( $_POST ) )
                                $selected_value = ( isset( $selected_attributes[ sanitize_title( $name ) ] ) ) ? $selected_attributes[ sanitize_title( $name ) ] : '';
                            else
                                $selected_value = isset( $_POST[ 'attribute_' . sanitize_title( $name ) ] ) ? $_POST[ 'attribute_' . sanitize_title( $name ) ] : '';

                            // Get terms if this is a taxonomy - ordered
                            if ( taxonomy_exists( sanitize_title( $name ) ) ) {

                                $terms = get_terms( sanitize_title($name), array('menu_order' => 'ASC') );

                                foreach ( $terms as $term ) {
                                    if ( ! in_array( $term->slug, $options ) ) continue;
                                    echo '<option value="' . $term->slug . '" ' . selected( $selected_value, $term->slug, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
                                }
                            } else {
                                foreach ( $options as $option )
                                    echo '<option value="' . $option . '" ' . selected( $selected_value, $option, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $option ) . '</option>';
                            }
                        }
                    ?>
                    </select> <?php
                    if ( sizeof($attributes) == $loop )
                        echo '<a class="reset_variations" href="#reset">'.__('Clear selection', 'woocommerce').'</a>';
                ?></td>
4

1 回答 1

0

remove - you can do it by pure php using str_replace

You have to give us more of your code to understand it.

于 2013-10-15T17:43:55.790 回答