122 lines
5.0 KiB
PHP
122 lines
5.0 KiB
PHP
|
<?php
|
|||
|
// Set the Current Author Variable $curauth
|
|||
|
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
|
|||
|
$userid = $curauth->ID;
|
|||
|
$user_name = get_the_author_meta('display_name', $userid);
|
|||
|
$user_description = get_the_author_meta('description', $userid);
|
|||
|
$avatar = get_avatar_url( $userid, array(
|
|||
|
'size' => 450,
|
|||
|
'default'=>'mystery',
|
|||
|
) );
|
|||
|
|
|||
|
get_header();
|
|||
|
$number_posts = 11;
|
|||
|
$offset_posts = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
|
|||
|
$search_tags = (isset($_GET['tags'])) ? $_GET['tags'] : [];
|
|||
|
$total_blog_posts = wp_count_posts()->publish;
|
|||
|
if ($offset_posts < 0) {
|
|||
|
$offset_posts = 0;
|
|||
|
}
|
|||
|
if (($offset_posts + 11) > $total_blog_posts) {
|
|||
|
$args = array(
|
|||
|
'numberposts' => $number_posts,
|
|||
|
'offset' => $total_blog_posts - 11,
|
|||
|
);
|
|||
|
$offset_posts -= 11;
|
|||
|
} else {
|
|||
|
$args = array(
|
|||
|
'numberposts' => $number_posts,
|
|||
|
'offset' => $offset_posts,
|
|||
|
);
|
|||
|
}
|
|||
|
$number_posts = count($posts);
|
|||
|
?>
|
|||
|
<script>
|
|||
|
localStorage.setItem("current-user", '<?php echo $userid ?>');
|
|||
|
</script>
|
|||
|
<div class="author-bio_container ppd-container layout">
|
|||
|
<div class="author-bio__img">
|
|||
|
<img src="<?php echo $avatar; ?>" />
|
|||
|
</div>
|
|||
|
<div class="author-bio__txt">
|
|||
|
<span class="author-bio__name-label">Автор</span>
|
|||
|
<p class="author-bio__name"><?php echo $user_name; ?></p>
|
|||
|
<p class="author-bio__description"><?php echo $user_description; ?></p>
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="layout ppd-container align-start column_mobile">
|
|||
|
<div class="layout column align-end links-container" style="min-width: 288px;">
|
|||
|
<div class="layout align-center" style="min-width: 288px; height: 36px; margin-left: 12px;">
|
|||
|
<div style="font-weight: 500; font-size: 17px; margin-right: 12px;">Мы в соц.сетях</div>
|
|||
|
<?php if (have_rows('social_links', 'option')) : ?>
|
|||
|
<?php while (have_rows('social_links', 'option')) : the_row(); ?>
|
|||
|
<a href="<?= get_sub_field('social_link'); ?>" target="_blank" style="width: 26px; height: 26px; margin: 0px 2px;"><img src="<?= get_sub_field('social_icon')['url'] ?>" style="width: 26px; height: 26px;" alt="logo"></a>
|
|||
|
<?php endwhile; ?>
|
|||
|
<?php endif; ?>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="layout ppd-container column">
|
|||
|
<?php global $PAGEN; $tag = get_queried_object(); $tag = $tag->slug; ?>
|
|||
|
<div class="layout article-cards wrap" id="articles-container" data-paged="<?php echo $PAGEN; ?>" data-title="Блог Пампаду — рассказываем о нас и о том, как зарабатывать на страховании" data-total="<?php echo get_pages_count($tag); ?>">
|
|||
|
<?php
|
|||
|
global $post;
|
|||
|
$blog_posts_offset = 0;
|
|||
|
$numberposts = 12;
|
|||
|
$banner_display = true;
|
|||
|
$args = array(
|
|||
|
'category_name' => 'Blog Post',
|
|||
|
'author' => $curauth->ID,
|
|||
|
'numberposts' => $numberposts,
|
|||
|
'offset' => $blog_posts_offset,
|
|||
|
);
|
|||
|
if (!empty($terms)) {
|
|||
|
foreach ($terms as $term) {
|
|||
|
if(is_tag($term->slug)) {
|
|||
|
$args['tag'] = $term->slug;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
$blog_posts = get_posts($args);
|
|||
|
if ($blog_posts) {
|
|||
|
$posts_counter = 0;
|
|||
|
foreach ($blog_posts as $blog_post) {
|
|||
|
if ($posts_counter+1 < $numberposts) {
|
|||
|
$post = $blog_post;
|
|||
|
setup_postdata($post);
|
|||
|
if($posts_counter==3){
|
|||
|
echo get_template_part('blog-posts/blog-post-small');
|
|||
|
echo $userid;
|
|||
|
if($blog_posts_offset==0){
|
|||
|
echo get_template_part('blog-posts/blog-banner');
|
|||
|
}
|
|||
|
}else if($posts_counter==6){
|
|||
|
echo get_template_part('blog-posts/blog-post-large');
|
|||
|
}else{
|
|||
|
echo get_template_part('blog-posts/blog-post-small');
|
|||
|
echo $userid;
|
|||
|
}
|
|||
|
wp_reset_postdata();
|
|||
|
}
|
|||
|
$posts_counter++;
|
|||
|
}
|
|||
|
}
|
|||
|
?>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<?php if ($wp_query->max_num_pages > 1) : ?>
|
|||
|
<script>
|
|||
|
var ajaxurl = '<?php echo site_url(); ?>/wp-admin/admin-ajax.php';
|
|||
|
var posts_vars = '<?php echo serialize($wp_query->query_vars); ?>';
|
|||
|
var current_page = <?php echo (get_query_var('paged')) ? get_query_var('paged') : 1; ?>;
|
|||
|
var max_pages = '<?php echo $wp_query->max_num_pages; ?>';
|
|||
|
</script>
|
|||
|
<button id="loadmore">Показать ещё</button>
|
|||
|
<?php endif; ?>
|
|||
|
<div class="layout ppd-container">
|
|||
|
<?php if ($posts_counter >= $numberposts):?>
|
|||
|
<div id="show-more" class="btn show-more" style="align-self: center; margin: 36px auto 60px; width: 213px; text-align: center; cursor: pointer;"><span>Показать ещё</span></div>
|
|||
|
<?php endif;?>
|
|||
|
</div>
|
|||
|
<?php get_footer(); ?>
|