You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.1 KiB
84 lines
3.1 KiB
<?php
|
|
/**
|
|
* Template Name: Main Page
|
|
* Description: Front page template
|
|
*/
|
|
?>
|
|
|
|
|
|
<?php
|
|
function theme_enqueue_scripts() {
|
|
wp_enqueue_style('gp-front-page-materialize-css', get_template_directory_uri() . '/static/css/libs/materialize.min.css');
|
|
wp_enqueue_style('gp-front-page-style', get_template_directory_uri() . '/static/css/front-page.css');
|
|
wp_enqueue_script( 'gp-front-page-materialize', get_template_directory_uri() . '/static/js/libs/materialize.min.js', array(), null, true );
|
|
wp_enqueue_script( 'gp-front-page-main', get_template_directory_uri() . '/static/js/front-page.js', array(), null, true );
|
|
}
|
|
add_action('wp_enqueue_scripts', 'theme_enqueue_scripts');
|
|
|
|
// Создаем функцию для получения постов
|
|
function get_blog_posts_data() {
|
|
$args = array(
|
|
'post_type' => 'post',
|
|
'posts_per_page' => 6,
|
|
);
|
|
|
|
$posts = new WP_Query($args);
|
|
$formatted_posts = array();
|
|
|
|
if ($posts->have_posts()) {
|
|
while ($posts->have_posts()) {
|
|
$posts->the_post();
|
|
|
|
$formatted_post = array(
|
|
'title' => get_the_title(),
|
|
'link' => get_permalink(),
|
|
'excerpt' => get_the_excerpt(),
|
|
'thumbnail' => has_post_thumbnail()
|
|
? get_the_post_thumbnail_url(get_the_ID(), 'full')
|
|
: get_template_directory_uri() . "/static/front-page/img/blog_card-img.jpg"
|
|
);
|
|
|
|
$formatted_posts[] = $formatted_post;
|
|
}
|
|
wp_reset_postdata();
|
|
}
|
|
|
|
return $formatted_posts;
|
|
}
|
|
|
|
|
|
$context = Timber::get_context();
|
|
$context['slider'] = get_field('slider');
|
|
$context['about_title'] = get_field('about_title');
|
|
$context['about_desc'] = get_field('about_desc');
|
|
$context['about_img'] = get_field('about_img');
|
|
$context['about_img_m'] = get_field('about_img_m');
|
|
$context['about_list'] = get_field('about_list');
|
|
$context['about_comp_text'] = get_field('about_comp_text');
|
|
$context['about_comp_logo'] = get_field('about_comp_logo');
|
|
$context['about_rev'] = get_field('about_rev');
|
|
$context['reviews_repeater'] = get_field('reviews_repeater');
|
|
$context['blog_posts'] = get_blog_posts_data();
|
|
$context['about_rev_title'] = get_field('about_rev_title');
|
|
$context['q_title'] = get_field('q_title');
|
|
$context['reviews_title'] = get_field('reviews_title');
|
|
$context['q_1'] = get_field('q_1');
|
|
$context['q_2'] = get_field('q_2');
|
|
$context['q_3'] = get_field('q_3');
|
|
$context['q_4'] = get_field('q_4');
|
|
$context['q_5'] = get_field('q_5');
|
|
$context['promo'] = get_field('promo');
|
|
$context['promo_text'] = get_field('promo_text');
|
|
|
|
$context['show_about'] = get_field('about_show');
|
|
$context['show_promo'] = get_field('promo_show');
|
|
$context['show_rev'] = get_field('vet_show');
|
|
$context['show_q'] = get_field('quiz_show');
|
|
$context['show_blog'] = get_field('blog_show');
|
|
$context['reviews'] = get_field('reviews');
|
|
$context['sub_title'] = get_field('sub_title');
|
|
$context['sub_text'] = get_field('sub_text');
|
|
|
|
Timber::render('_pages/front-page.twig', $context);
|
|
|
|
?>
|
|
|