function woa_add_full_slider() { ?>
<?php
if ( is_home() ) {
echo do_shortcode("[huge_it_slider id=2 percentwidth=100 restrict_to_home ]");
}
?>
add_action( 'wp_enqueue_scripts', 'theme_add_styles' );
function theme_add_styles() {
wp_enqueue_style( 'reset', get_stylesheet_uri() );
}
function search_by_title_only( $search, &$wp_query )
{
global $wpdb;
$q = $wp_query->query_vars;
$search = '';
$and = '';
foreach ( (array) $q['search_terms'] as $term ) {
$search .= "{$and}($wpdb->posts.post_title LIKE '%{$term}%')";
$and = ' AND ';
}
if ( ! empty( $search ) ) {
$search = " AND ({$search}) ";
}
return $search;
}
add_filter( 'posts_search', 'search_by_title_only', 500, 2 );
function the_breadcrumb() {
echo '<ul id="crumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a></li>";
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li> ');
if (is_single()) {
echo "</li><li>";
the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li>';
echo the_title();
echo '</li>';
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
echo '</ul>';
}
// удаляем кнопку "В корзину" если нужно
add_filter('woocommerce_is_purchasable', 'remove_add_to_cart_button');
function remove_add_to_cart_button($purchaseable_product, $product) {
return ($product->is_in_stock() ? false : $purchaseable_product);
}
//выводим надпись "Нет в наличии"
add_filter( 'woocommerce_get_availability', 'check_availability', 1, 2);
function check_availability( $availability, $product ) {
if ( !$product->is_in_stock() ) {
$availability['availability'] = 'Нет в наличии';
}
return $availability;
}
$prod_cat_args = array(
'taxonomy' => 'product_cat',
'orderby' => 'id', // здесь по какому полю сортировать
'hide_empty' => false, // скрывать категории без товаров или нет
'parent' => 0 // id родительской категории
);
$woo_categories = get_categories( $prod_cat_args );
foreach ( $woo_categories as $woo_cat ) {
$woo_cat_id = $woo_cat->term_id; //category ID
$woo_cat_name = $woo_cat->name; //category name
$woo_cat_slug = $woo_cat->slug; //category slug
echo '<div class="main-cat-item">';
$category_thumbnail_id = get_woocommerce_term_meta($woo_cat_id, 'thumbnail_id', true);
$thumbnail_image_url = wp_get_attachment_url($category_thumbnail_id);
echo '<img src="' . $thumbnail_image_url . '"/>';
echo '<h2>';
echo '<a href="' . get_term_link( $woo_cat_id, 'product_cat' ) . '">' . $woo_cat_name . '</a>;
echo '</h2>';
echo "</div>\n";
}
SCSS:
.main-cat-item {
padding: 1em;
position: relative;
h2 {
font-size: 2em;
position: absolute;
bottom: 0;
right: 0;
padding: 1.5em 1.5em;
text-shadow: 0 1px 8px black;
a {
color: white;
}
}
}