$array = array();
$i = 1;
// собираем занчения в массив
while ( $i <= 15 ) {
if ( $field = get_field( 'item' . $i ) ) {
$array[] = $field;
}
$i++;
}
// выводим, если массив не пустой
if ( !empty( $array ) ) {
echo '<ul>';
foreach ( $array as $key => $value ) {
echo '<li>' . $value . '</li>';
}
echo '</ul>';
}
add_filter( 'query_vars', 'add_query_vars' );
function add_query_vars( $qvars ) {
$qvars[] = 'month';
$qvars[] = 'year';
return $qvars;
}
get_query_var()
if ( $month = get_query_var( 'month', false ) ) {
# code...
}
add_query_arg()
$link = add_query_arg( [ 'month' => '11', 'year' => '2021', ], get_home_link() );
if ( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_1',
'title' => 'My Group',
'fields' => array (),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
));
acf_add_local_field(array(
'key' => 'field_1',
'label' => 'Sub Title',
'name' => 'sub_title',
'type' => 'text',
'parent' => 'group_1'
));
endif;
wp_head()
, а в файле footer.php функция wp_footer()
. Проще всего сгенерировать стартовый шаблон на underscores.me wc_get_orders()
и циклом выводите ту разметку, которая вам нужна$args = array(
'author' => get_current_user_id();
);
$orders = wc_get_orders( $args );
foreach ( $orders as $key => $order ) {
// данные заказа
$data = $order->get_data();
echo $data['id'];
echo $data['parent_id'];
echo $data['status'];
echo $data['currency'];
echo $data['version'];
echo $data['payment_method'];
echo $data['payment_method_title'];
echo $data['payment_method'];
echo $data['payment_method'];
// еще данные
echo $data['discount_total'];
echo $data['discount_tax'];
echo $data['shipping_total'];
echo $data['shipping_tax'];
echo $data['cart_tax'];
echo $data['total_tax'];
echo $data['customer_id'];
// ... и все в том же духе
}
customize_register
, добавлять опции и элементы управления с помощью методов add_setting()
и add_control()
$wp_customize->add_setting( 'themeslug_textarea_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum Dolor Sit amet',
'sanitize_callback' => 'sanitize_textarea_field',
) );
$wp_customize->add_control( 'themeslug_textarea_setting_id', array(
'type' => 'textarea',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Text Area' ),
'description' => __( 'This is a custom textarea.' ),
) );
/*
Template Name: Шаблон с контактами
Template Post Type: page
*/
add_action( 'pre_get_posts', 'repeater_dynamic_query' );
function repeater_dynamic_query( $query ) {
if ( $query->get('post_type') === 'product' ) {
$tax_query['tax_query'] = array(
array(
'taxonomy' => 'pa_aktsiya',
'field' => 'slug',
'terms' => array( 'spetspredlozheniya' ),
'operator' => 'IN',
),
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => array( 'exclude-from-catalog' ),
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
$query->set( 'no_found_rows', true );
}
}