<?php get_header(); ?>

<div id="main-content" class="blog-article">
	<div class="container">
        <h1 class="blog-page-heading">Resources</h1>
		<div id="content-area" class="clearfix">
			<div id="left-area">

		<?php
			$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;

			$args = array(
				'post_type'      => 'post',
				'category_name'  => 'blogs', // change if your slug is different
				'paged'          => $paged,
				// No posts_per_page → will use Reading Settings
			);

			$query = new WP_Query($args);

			if ( $query->have_posts() ) :
				while ( $query->have_posts() ) : $query->the_post();

					$post_format = et_pb_post_format(); ?>

					<article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>

				<?php
					$thumb = '';
					$width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );
					$height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
					$classtext = 'et_pb_post_main_image';
					$titletext = get_the_title();
					$alttext = get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true );

					$thumbnail = get_thumbnail( $width, $height, $classtext, $alttext, $titletext, false, 'Blogimage' );
					$thumb = $thumbnail["thumb"];

					et_divi_post_format_content();

					if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) {
						if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) :
							printf(
								'<div class="et_main_video_container">%1$s</div>',
								et_core_esc_previously( $first_video )
							);
						elseif ( ! in_array( $post_format, array( 'gallery' ) ) && 'on' === et_get_option( 'divi_thumbnails_index', 'on' ) && '' !== $thumb ) : ?>
							
							<a class="entry-featured-image-url" href="<?php the_permalink(); ?>">
								<?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
							</a>

					<?php
						elseif ( 'gallery' === $post_format ) :
							et_pb_gallery_images();
						endif;
					}
				?>

				<?php if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) : ?>

					<h2 class="entry-title">
						<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
					</h2>

					<!-- ✅ Only Date (Author & Category Removed) -->
					<p class="post-meta">
						<?php echo get_the_date(); ?>
					</p>

					<?php
						if ( 'on' !== et_get_option( 'divi_blog_style', 'false' ) || ( is_search() && ( 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true ) ) ) ) {
							truncate_post( 270 );
						} else {
							the_content();
						}
					?>

				<?php endif; ?>

					</article>

			<?php
				endwhile;

				// Pagination
				if ( function_exists( 'wp_pagenavi' ) ) {
					wp_pagenavi( array( 'query' => $query ) );
				} else {
					the_posts_pagination();
				}

				wp_reset_postdata();

			else :
				get_template_part( 'includes/no-results', 'index' );
			endif;
		?>

			</div>

			<?php //get_sidebar(); ?>

		</div>
	</div>
</div>

<?php get_footer(); ?>