File Manager V1.5
FILE_CONTENT: blog.php
<?php
include 'header.php';
require_once 'admin/functions.php';
// Get published blog posts
$blog_posts = getPublishedBlogPosts();
?>
<section class="blog-section" style="margin-top:15%;">
<div class="auto-container">
<div class="sec-title">
<h3 style="color:#2ed0b0;">Latest Blog Posts</h3>
</div>
<div class="row clearfix">
<?php if ($blog_posts && $blog_posts->num_rows > 0): ?>
<?php while($post = $blog_posts->fetch_assoc()): ?>
<div class="news-block col-lg-4 col-md-6 col-sm-12">
<div class="inner-box">
<?php if ($post['image_url']): ?>
<div class="image">
<a href="blog-post.php?id=<?php echo $post['id']; ?>">
<img src="<?php echo htmlspecialchars($post['image_url']); ?>" alt="<?php echo htmlspecialchars($post['title']); ?>">
</a>
</div>
<?php endif; ?>
<div class="lower-content">
<ul class="post-meta">
<li><span class="fa fa-calendar"></span><?php echo date('M j, Y', strtotime($post['created_at'])); ?></li>
<li><span class="fa fa-user"></span><?php echo htmlspecialchars($post['author']); ?></li>
</ul>
<h3><a href="blog-post.php?id=<?php echo $post['id']; ?>"><?php echo htmlspecialchars($post['title']); ?></a></h3>
<div class="text">
<?php
// Show excerpt of the content
$excerpt = strip_tags($post['content']);
echo strlen($excerpt) > 200 ? substr($excerpt, 0, 200) . "..." : $excerpt;
?>
</div>
<a href="blog-post.php?id=<?php echo $post['id']; ?>" class="read-more">Read More <span class="fa fa-angle-right"></span></a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="col-12">
<p class="text-center">No blog posts available at the moment.</p>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php include 'footer.php'; ?>[ KEMBALI ]