File: /var/www/html/acharya-rajnikant-backup/wp-content/themes/aacharyarajnikant/sidebar.php
<div class="sidebar">
<?php if (is_active_sidebar('main-sidebar')) : ?>
<?php dynamic_sidebar('main-sidebar'); ?>
<?php else : ?>
<div class="sidebar__search">
<div class="section__header">
<h2>Search Now</h2>
</div>
<div class="section__wrapper">
<form role="search" method="get" action="<?php echo home_url('/'); ?>">
<input type="text" placeholder="Search" value="<?php echo get_search_query(); ?>" name="s">
<button type="submit"><i class="fas fa-search"></i></button>
</form>
</div>
</div>
<div class="sidebar__tab">
<div class="section__header">
<h2>Post Tag</h2>
</div>
<div class="section__wrapper">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="post-tab" data-bs-toggle="tab"
data-bs-target="#post" type="button" role="tab" aria-controls="post"
aria-selected="true">Recent Post</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="comment-tab" data-bs-toggle="tab"
data-bs-target="#comment" type="button" role="tab" aria-controls="comment"
aria-selected="false">Comments</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="post" role="tabpanel"
aria-labelledby="post-tab">
<div class="footer__post">
<div class="section__wrapper">
<?php
$recent_posts = new WP_Query(array(
'posts_per_page' => 3,
'post_status' => 'publish'
));
if ($recent_posts->have_posts()) :
while ($recent_posts->have_posts()) : $recent_posts->the_post();
?>
<div class="footer__post-item">
<div class="footer__post-inner">
<?php if (has_post_thumbnail()) : ?>
<div class="footer__post-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(80, 80)); ?></a>
</div>
<?php endif; ?>
<div class="footer__post-content">
<a href="<?php the_permalink(); ?>">
<h6><?php the_title(); ?></h6>
</a>
<p><i class="far fa-calendar-alt"></i> <?php echo get_the_date(); ?></p>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
</div>
</div>
</div>
<div class="tab-pane fade" id="comment" role="tabpanel"
aria-labelledby="comment-tab">
<div class="blog__comments-details">
<ul>
<?php
$comments = get_comments(array(
'number' => 4,
'status' => 'approve'
));
foreach ($comments as $comment) :
?>
<li>
<div class="blog__comments-thumb">
<?php echo get_avatar($comment, 50); ?>
</div>
<div class="blog__comments-content">
<h6><?php echo esc_html($comment->comment_author); ?></h6>
<p><?php echo wp_trim_words($comment->comment_content, 10); ?></p>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar__tag">
<div class="footer__tags">
<div class="section__header">
<h2>Post Tag</h2>
</div>
<div class="section__wrapper">
<?php
$tags = get_tags();
if ($tags) :
echo '<ul>';
foreach ($tags as $tag) {
echo '<li><a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
}
echo '</ul>';
endif;
?>
</div>
</div>
</div>
<div class="sidebar__catagory">
<div class="section__header">
<h2>Categories</h2>
</div>
<div class="section__wrapper">
<ul>
<?php
$categories = get_categories();
foreach ($categories as $category) {
echo '<li><a href="' . get_category_link($category->term_id) . '"><i class="fas fa-chevron-right"></i>' . $category->name . '</a></li>';
}
?>
</ul>
</div>
</div>
<?php endif; ?>
</div>