function print_root_category() {
if ( ! is_single() ) {
return;
}
$post_categories = wp_get_post_categories( get_the_ID(), [ 'fields' => 'all' ] );
if ( ! count( $post_categories ) ) {
return;
}
$post_category = $post_categories[0];
if ( ! $post_category->parent ) {
return;
}
$parents = get_ancestors( $post_category->term_id, $post_category->taxonomy );
$root_category_id = array_pop( $parents );
echo 'Смотрите так же <a href="' . get_category_link( $root_category_id ) . '">' . get_cat_name( $root_category_id ) . '</a>';
}
echo '<input type="text" id= "lft_new_field" name="lft_new_field" value="Ex:14" size="25" />';
echo '<input type="text" id= "lft_new_field" name="lft_new_field" value="' . get_post_meta( $post->ID, '_my_meta_value_key', true ) . '" size="25" />';
$default_category_id = get_option( 'default_product_cat', 0 );
if ( is_tax( 'product_cat', $default_category_id ) ) {
echo 'Default Category!';
}
add_filter('pre_get_posts',function($filter) use ($file) {
return exc_post($filter, $file);
});
add_filter('pre_get_posts','exc_post', function($filter) use ($file) {
return exc_post($filter, $file);
});
$date = new DateTime('2000-01-01');
echo $date->format('F Y');
add_action( 'wp_enqueue_scripts', 'spon_style', 100 );
https://realia.ua/prodazha-kvartir/room-2/type_object-ctudiya-2_h_i_bolee_urovnej/area-ot-25/cost-ot-500000/
add_action( 'woocommerce_product_options_pricing', 'custom_woocommerce_product_options_pricing' );
function custom_woocommerce_product_options_pricing() {
$price_index = '_custom_price';
woocommerce_wp_text_input(
array(
'id' => $price_index,
'value' => get_post_meta( get_the_ID(), $price_index, true ),
'data_type' => 'price',
'label' => __( 'Custom price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')'
)
);
}
add_action( 'woocommerce_admin_process_product_object', 'custom_woocommerce_admin_process_product_object', 10, 1 );
function custom_woocommerce_admin_process_product_object( $product ) {
$price_index = '_custom_price';
$price = wc_clean( wp_unslash( $_POST[ $price_index ] ) );
update_post_meta( $product->get_id(), $price_index, $price );
}
$price_index = '_custom_price';
echo wc_price( get_post_meta( get_the_ID(), $price_index, true ) );
<?php
global $product;
if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) {
return;
}
$rating_count = $product->get_rating_count();
$review_count = $product->get_review_count();
$average = $product->get_average_rating();
if ( $rating_count > 0 ) : ?>
<div class="woocommerce-product-rating">
<?php echo wc_get_rating_html( $average, $rating_count ); ?>
<?php echo '(' . $review_count . ')'; ?> <!-- Количество отзывов -->
</div>
<?php endif; ?>