<input type="hidden" value="post" name="post_type" />
. В value
можете вписать тип поста. product, post, order и т.д<input type="hidden" value="1" name="sentence" />
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ) ?>" >
<div class="stylevision-sear">
<div class="stylevision-sear__block">
<input class="stylevision-sear__input" type="search" value="<?php echo get_search_query() ?>" name="s" id="s site-search" placeholder="Example: what to wear to prom" aria-label="Search through site content">
<input type="hidden" value="post" name="post_type" />
<input type="hidden" value="1" name="sentence" />
</div>
<button class="stylevision-sear__btn">Search</button>
</div>
</form>
$min_price = "1";
$max_price = "99000";
if(isset($_POST['min_price'])) $min_price = $_POST['min_price'];
if(isset($_POST['max_price'])) $max_price = $_POST['max_price'];
echo "Ваш min_price: $min_price <br> Ваш max_price: $max_price <br><br>";
<form action="" method="post" >
<div class="left">
<label>
от <input name="min_price" type="number" value="<?php echo $min_price?>">
</label>
<div class="minus">
<img src="<?php bloginfo('template_directory')?>/accets/img/minus.png" alt="">
</div>
<label>
до <input name="max_price" type="number" value="<?php echo $max_price?>">
</label>
</div>
<button>го</button>
</form>
<?php
$query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 6,
'meta_query' => array(
'max_price' => array(
'key' => 'цена',
'value' => $max_price,
'type' => 'NUMERIC',
'compare' => '<=',
),
'min_price' => array(
'key' => 'цена',
'value' => $min_price,
'type' => 'NUMERIC',
'compare' => '>=',
),
),
'orderby' => 'max_price,min_price,minimal_price',
) );
?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<?php
get_template_part( 'loop/item_type1', 'loop' );
?>
<?php endwhile; ?>
<?php
wp_reset_query();
?>
$api_response = wp_remote_post( 'http://localhost/ecler/wp-json/wc/v3/products', array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'ЛОГИН:ПАРОЛЬ' )
),
'body' => array(
'name' => 'My test2', // product title
'status' => 'publish', // product status, default: publish
'categories' => array(
array(
'id' => 15 // each category in a separate array
),
// array(
// 'id' => 10
// )
),
'regular_price' => '9.99' // product price
// more params http://woocommerce.github.io/woocommerce-rest-api-docs/?shell#product-properties
)
) );
$body = json_decode( $api_response['body'] );
//print_r( $body );
if( wp_remote_retrieve_response_message( $api_response ) === 'Created' ) {
echo 'The product ' . $body->name . ' has been created';
}
print_r( $body );
// print_r( $api_response );
$('.price_min_max_btn').on('click',function() {
const
min = $('.price_min').val(),
max = $('.price_max').val();
$('.item_block_filter').each(function() {
hidden_true = $(this).is(":hidden");
const price = +this.dataset.price;
$(this).toggle((!min && !hidden_true || min <= price && !hidden_true) && (!max && !hidden_true || price <= max && !hidden_true));
});
});
<?php
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
);
$product_categories = get_terms( $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
echo '<div class="col-md-6 col-sm-12 col-xs-12">';
echo '<article class="type-post">';
echo '<div class="entry-cover" style="width: 388px; height: 295px;">';
echo '<a href="' . get_term_link( $product_category ) . '"><img style="background-image: url('. wp_get_attachment_url( $thumbnail_id ) .')!important;background-size: 100%;background-repeat: no-repeat;background-size: cover; width: 100%; height: 100%;" /></a>';
echo '</div>';
echo '<div class="entry-block">';
echo '<div class="entry-title">';
echo '<a href="' . get_term_link( $product_category ) . '" title="' . $product_category->name . '"><h3>' . $product_category->name . '</h3></a>';
echo '</div>';
echo '<hr>';
echo '<div class="entry-content">';
echo '<p>' . $product_category->description . '</p>';
echo '</div>';
echo '</div>';
echo '</article>';
echo '</div>';
}
}
?>