<?php
$actualLoop = new WP_Query(array(
'posts_per_page' => 5,
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'is_actual',
'value' => '1',
'compare' => 'LIKE',
)
),
));
if ( $actualLoop->have_posts() ) : ?>
<div class="sidebar-inner-right">
<h2 class="sidebar-title"><?php _e('Актуально') ?></h2>
<?php while ( $actualLoop->have_posts() ) : $actualLoop->the_post();
$is_actual = get_field('is_actual');
?>
<?php if ($is_actual): ?>
<a href="<?php the_permalink() ?>">
<div class="news-img-block">
<div class="img-wrapper">
<?php if (has_post_thumbnail()) {
the_post_thumbnail('blog-thumb');
}else{
echo '<img class="no-img" src="'. get_bloginfo('template_directory'). '/assets/img/no-thumbnail.jpg' . '" alt="no image">';
}?>
</div>
<h3 class="news-img-block-title"><?php trim_title_words(10, '...'); ?></h3>
<div class="news-block-info">
<div class="news-block-info-item news-block-date">
<?php echo theCustomDate() ?>
</div>
<div class="news-block-info-item news-block-views">
<?php _e('Переглядів:') ?>
<?php echo getPostViews(get_the_ID()); ?>
</div>
<div class="news-block-info-item news-block-comments">
<?php echo num_comments() ?>
</div>
</div>
<div class="news-block-excerpt">
<?php echo kama_excerpt( array('maxchar'=>80) ); ?>
</div>
</div>
</a>
<?php endif ?>
<?php endwhile;?>
</div>
<?php endif; wp_reset_query(); ?>
<?php if ( have_posts() ) : $ir = 0; while ( have_posts() ) : the_post();
if ( $ir == 0 ) {
get_template_part( 'template-parts/article-wide' );
} else {
get_template_part( 'template-parts/article' );
}
$ir++; endwhile; endif; ?>
// Move WooCommerce subcategory list items into heir own <ul> separate from the product <ul>
add_action( 'init', 'move_subcat_lis' );
function move_subcat_lis() {
// Remove the subcat <li>s from the old location.
remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );
add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 40 );
add_action( 'woocommerce_before_shop_loop', 'msc_maybe_show_product_subcategories', 50 );
add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 60 );
}
//Conditonally start the product loop with a <ul> contaner if subcats exist.
function msc_product_loop_start() {
$subcategories = woocommerce_maybe_show_product_subcategories();
if ( $subcategories ) {
echo '<ul class="archive-category-wrapper">';
}
}
//Print the subcat <li>s in our new location.
function msc_maybe_show_product_subcategories() {
echo woocommerce_maybe_show_product_subcategories();
}
//Conditonally end the product loop with a </ul> if subcats exist.
function msc_product_loop_end() {
$subcategories = woocommerce_maybe_show_product_subcategories();
if ( $subcategories ) {
echo '</ul>';
}
}
<nav class="site-nav">
<ul id="navigation">
<li data-menuanchor="about-us">
<a href="#about-us" data-lang="about_academy">Про академию</a>
</li>
<li data-menuanchor="what-we-offer">
<a href="#what-we-offer" data-lang="proposal">Что мы предлагаем</a>
</li>
<li data-menuanchor="your-benefits">
<a href="#your-benefits" data-lang="your_result">Что ты получишь</a>
</li>
<li data-menuanchor="our-blog">
<a href="#our-blog" data-lang="blog">Блог</a>
</li>
<li data-menuanchor="testimonials">
<a href="#testimonials" data-lang="feedback">Отзывы</a>
</li>
<li data-menuanchor="contacts">
<a href="#contacts" data-lang="contacts">Контакты</a>
</li>
<li class="language-switcher-wrapper">
<button class="language-switcher ua">UA</button>
</li>
</ul>
</nav>
{
"about_academy": "Про Академию",
"proposal": "Что мы предлагаем",
"your_result": "Что ты получишь",
"feedback": "Что говорят выпускники",
"blog": "Блог",
"contacts": "Контакты",
"our_mission_main": "Наша миссия"
}
{
"about_academy": "Про Академію",
"proposal": "Що ми пропонуємо",
"your_result": "Що ти отримаєш",
"feedback": "Що кажуть випускники",
"blog": "Блог",
"contacts": "Контакти",
"our_mission_main": "Наша місія"
}
(function($) {
function Translate() {
//initialization
this.init = function(attribute, lng) {
this.attribute = attribute;
this.lng = lng;
};
//translate
this.process = function() {
var _self = this;
var xrhFile = new XMLHttpRequest();
//load content data
xrhFile.open("GET", "./translations/"+this.lng+".json", false);
xrhFile.onreadystatechange = function () {
if(xrhFile.readyState === 4) {
if(xrhFile.status === 200 || xrhFile.status == 0) {
var LngObject = JSON.parse(xrhFile.responseText);
console.log(LngObject["name1"]);
var allDom = document.getElementsByTagName("*");
for(var i =0; i < allDom.length; i++){
var elem = allDom[i];
var key = elem.getAttribute(_self.attribute);
if(key != null) {
console.log(key);
elem.innerHTML = LngObject[key];
}
}
}
}
};
xrhFile.send();
};
}
// Change language
function loadNewLang(new_lang) {
var translate = new Translate();
var currentLng = new_lang;
var attributeName = 'data-lang';
translate.init(attributeName, currentLng);
translate.process();
}
loadNewLang('ua');
$('.language-switcher').on('click', function(e) {
e.preventDefault();
$('.preloader').removeAttr('style');
if($(this).hasClass('ru')) {
$(this).toggleClass('ru ua').text('UA');
loadNewLang('ua');
ln_preloader();
} else if ($(this).hasClass('ua')) {
$(this).toggleClass('ua ru').text('RU');
loadNewLang('ru');
ln_preloader();
}
});
})(jQuery);
add_action( 'woocommerce_after_shop_loop', 'your_theme_upsell_display', 15 );
function your_theme_upsell_display () {
if ( is_product_category() ) {
woocommerce_upsell_display();
}
}
add_action( 'woocommerce_after_shop_loop', 'your_theme_output_related_products', 20 );
function your_theme_output_related_products () {
if ( is_product_category() ) {
woocommerce_output_related_products();
}
}
function wpse28145_add_custom_types( $query ) {
if( is_tag() && $query->is_main_query() ) {
// this gets all post types:
$post_types = get_post_types();
// alternately, you can add just specific post types using this line instead of the above:
// $post_types = array( 'post', 'your_custom_type' );
$query->set( 'post_type', $post_types );
}
}
add_filter( 'pre_get_posts', 'wpse28145_add_custom_types' );
// Register Testimonials Post Type
function testimonials_post_type() {
$labels = array(
'name' => _x( 'Testimonials', 'Post Type General Name', 'youth-worker' ),
'singular_name' => _x( 'Testimonial', 'Post Type Singular Name', 'youth-worker' ),
'menu_name' => __( 'Testimonials', 'youth-worker' ),
'name_admin_bar' => __( 'Testimonials', 'youth-worker' ),
'archives' => __( 'Testimonial Archives', 'youth-worker' ),
'attributes' => __( 'Testimonial Attributes', 'youth-worker' ),
'parent_item_colon' => __( 'Parent Item:', 'youth-worker' ),
'all_items' => __( 'All Testimonials', 'youth-worker' ),
'add_new_item' => __( 'Add New Testimonial', 'youth-worker' ),
'add_new' => __( 'Add New', 'youth-worker' ),
'new_item' => __( 'New Testimonial', 'youth-worker' ),
'edit_item' => __( 'Edit Testimonial', 'youth-worker' ),
'update_item' => __( 'Update Testimonial', 'youth-worker' ),
'view_item' => __( 'View Testimonial', 'youth-worker' ),
'view_items' => __( 'View Testimonials', 'youth-worker' ),
'search_items' => __( 'Search Testimonial', 'youth-worker' ),
'not_found' => __( 'Not found', 'youth-worker' ),
'not_found_in_trash' => __( 'Not found in Trash', 'youth-worker' ),
'featured_image' => __( 'Featured Image', 'youth-worker' ),
'set_featured_image' => __( 'Set featured image', 'youth-worker' ),
'remove_featured_image' => __( 'Remove featured image', 'youth-worker' ),
'use_featured_image' => __( 'Use as featured image', 'youth-worker' ),
'insert_into_item' => __( 'Insert into item', 'youth-worker' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'youth-worker' ),
'items_list' => __( 'Testimonials list', 'youth-worker' ),
'items_list_navigation' => __( 'Testimonials list navigation', 'youth-worker' ),
'filter_items_list' => __( 'Filter Testimonials list', 'youth-worker' ),
);
$args = array(
'label' => __( 'Testimonial', 'youth-worker' ),
'description' => __( 'Post Type for testimonials', 'youth-worker' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'post-formats' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 30,
'menu_icon' => 'dashicons-format-status',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'testimonials', $args );
}
add_action( 'init', 'testimonials_post_type', 0 );
$testimonials = new WP_Query(array(
'post_type' => 'testimonials',
'orderby' => 'date',
'order' => 'DESC',
));
<?php if ( $testimonials->have_posts() ) : ?>
<?php while ( $testimonials->have_posts() ) : $testimonials->the_post(); ?>
<div class="testimonial-item">
blabla
</div>
<?php endif; ?>
<?php endwhile;?>
<?php endif; wp_reset_postdata(); ?>