add_action( 'woocommerce_product_after_variable_attributes', 'cr_variable_fields', 10, 3 );
add_action( 'woocommerce_product_after_variable_attributes_js', 'cr_variable_fields_js' );
add_action( 'woocommerce_process_product_meta_variable', 'save_cr_variable_fields', 10, 1 );
/**
* Создает новое поле
*/
function cr_variable_fields( $loop, $variation_data, $variation ) {
?>
<tr>
<td>
<?php
woocommerce_wp_text_input(
array(
'id' => '_text_field['.$loop.']',
'label' => __( 'Мое текстовое поле', 'woocommerce' ),
'placeholder' => __( 'Подсказка', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Введите ваше значение.', 'woocommerce' ),
'value' => get_post_meta( $variation->ID, '_text_field', true )
)
);
?>
</td>
</tr>
<?php
}
/**
* Создает поле нового варианта
*/
function cr_variable_fields_js() {
?>
<tr>
<td>
<?php
woocommerce_wp_text_input(
array(
'id' => '_text_field[ + loop + ]',
'label' => __( 'Мое текстовое поле', 'woocommerce' ),
'placeholder' => __( 'Подсказка', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Введите ваше значение.', 'woocommerce' ),
'value' => ''
)
);
?>
</td>
</tr>
<?php
}
/**
* Сохраняет поле
*/
function save_cr_variable_fields( $post_id ) {
if (isset( $_POST['variable_sku'] ) ) :
$variable_sku = $_POST['variable_sku'];
$variable_post_id = $_POST['variable_post_id'];
$_text_field = $_POST['_text_field'];
for ( $i = 0; $i < sizeof( $variable_sku ); $i++ ) :
$variation_id = (int) $variable_post_id[$i];
if ( isset( $_text_field[$i] ) ) {
update_post_meta( $variation_id, '_text_field', stripslashes( $_text_field[$i] ) );
}
endfor;
endif;
}
add_action('woocommerce_shop_loop_item_title' ,'woocommerce_template_single_excerpt',20);
<article id="post-<?php echo $post->ID; ?>" <?php post_class(); ?>>
// содержимое записи
</article>
article.category-foo:before {
width: 30px;
height: 30px;
content: ' ';
background-image: url('%img-url%');
display: block;
position: absolute;
top: -25px;
left: -25px;
}
add_filter('sanitize_file_name', '%ваша функция транслитерации%');
$args = array(
'orderby' => array(
'meta_value_num',
),
'order' => 'ASC',
'meta_key' => '%ключ поля%'
);
$args = unserialize(stripslashes($_POST['query']));
$args['paged'] = $_POST['page'] + 1; // следующая страница
$args['post_status'] = 'publish';
$first_page_post_count = 9;
$empty_pages_post_count = 8;
if ($args['paged'] > 1) {
$posts_per_page = $empty_pages_post_count;
if ($args['paged'] == 2) {
$offset = $first_page_post_count;
} else {
$offset = $first_page_post_count + ( $empty_pages_post_count * ($args['paged'] - 2));
}
} else {
$offset = 0;
$posts_per_page = $first_page_post_count;
}
$args['posts_per_page'] =>$posts_per_page;
$args['offset'] => $offset;
$q = new WP_Query($args);
register_activation_hook(__FILE__, 'activate_options');
add_options_page('RDolls Category Adder', 'RDolls Category Setting', 8, __FILE__, 'plugin_setting_page');
add_options_page('RDolls Category Adder', 'RDolls Category Setting', 'manage_options', __FILE__, 'plugin_setting_page');
<?php
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
if( $image_attributes ) {
?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
<?php } ?>
<div class="sider_container">
<div class="slide_item">
<?php if( ! empty( $brainiak['opt-slides'] ) ) {
foreach ( $brainiak['opt-slides'] as $val )
echo '<img src="' . $val['image']. '" alt="' . $val['title'] .'" class="img-responsive">';
} ?>
</div>
</div>
printf('<img src="%s" alt="%s" class="img-responsive">', $val['image'], $val['title']);