HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/domains/morsunivers.dk/public_html/wp-content/themes/mts_dropshipping/page-blog.php
<?php
/**
 * Template Name: Blog Page
 */
$mts_options = get_option( MTS_THEME_NAME );
get_header(); ?>

<div class="blog-background page-title">
	<div class="container">
		<h1 class="title"><?php esc_html_e( 'Blog', 'dropshipping' ); ?></h1>
	</div>
</div>

<div id="page" class="blog">
	<div class="article">
		<div id="content_box">
			<?php
			if ( get_query_var( 'paged' ) && get_query_var( 'paged' ) > 1 ) {
				$paged = get_query_var( 'paged' ); // phpcs:ignore
			} elseif ( get_query_var( 'page' ) && get_query_var( 'page' ) > 1 ) {
				$paged = get_query_var( 'page' ); // phpcs:ignore
			} else {
				$paged = 1; // phpcs:ignore
			}
			$args = array(
				'post_type'           => 'post',
				'post_status'         => 'publish',
				'paged'               => $paged,
				'ignore_sticky_posts' => 1,
			);
			$latest_posts_query = new WP_Query( $args );

			global $wp_query;
			// Put default query object in a temp variable.
			$tmp_query = $wp_query;
			// Now wipe it out completely.
			$wp_query = null; // phpcs:ignore
			// Re-populate the global with our custom query.
			$wp_query = $latest_posts_query;

			$blog_layout = ! empty( $mts_options['mts_blog_posts_layout'] ) ? $mts_options['mts_blog_posts_layout'] : 'default';

			if ( ! is_paged() ) {
				$featured_categories = [];
				if ( ! empty( $mts_options['mts_featured_categories'] ) ) {
					foreach ( $mts_options['mts_featured_categories'] as $section ) {
						$category_id           = $section['mts_featured_category'];
						$featured_categories[] = $category_id;
						$posts_num             = $section['mts_featured_category_postsnum'];
						if ( $category_id == 'latest' ) { // phpcs:ignore
							?>
							<div class="article-wrapper <?php echo $blog_layout; ?>">
								<h3 class="featured-category-title"><?php esc_html_e( 'Latest', 'dropshipping' ); ?></h3>
									<?php
									$j = 0;
									if ( $latest_posts_query->have_posts() ) :
										while ( $latest_posts_query->have_posts() ) :
											$latest_posts_query->the_post();
											?>
											<article class="latestPost excerpt <?php echo( ++$j % 3 == 0 ) ? 'last' : ''; ?>">
												<?php mts_archive_post(); ?>
											</article>
											<?php
										endwhile;
									endif;

									if ( 0 !== $j ) { // No pagination if there is no posts.
										mts_pagination();
									}

									// Restore original query object.
									$wp_query = $tmp_query; // phpcs:ignore
									// Be kind; rewind.
									wp_reset_postdata();

									?>
							</div>							
							<?php
						} else {
							?>
							<div class="article-wrapper <?php echo $blog_layout; ?>">
								<h3 class="featured-category-title featured-title">
									<a href="<?php echo esc_url( get_category_link( $category_id ) ); ?>" title="<?php echo esc_attr( get_cat_name( $category_id ) ); ?>">
										<?php echo esc_html( get_cat_name( $category_id ) ); ?>
									</a>
								</h3>
								<?php
								$j = 0;
								// category query.
								$cat_query = new WP_Query( 'cat=' . $category_id . '&posts_per_page=' . $posts_num );
								if ( $cat_query->have_posts() ) :
									while ( $cat_query->have_posts() ) :
										$cat_query->the_post();
										?>
										<article class="latestPost excerpt <?php echo ( ++$j % 3 == 0 ) ? 'last' : ''; ?>">
											<?php mts_archive_post(); ?>
										</article>
										<?php
										endwhile;
									endif;
									wp_reset_postdata();
								?>
							</div>	
							<?php
						}
					}
				}
			} else {
				?>
				<div class="article-wrapper <?php echo $blog_layout; ?>">
					<?php
					$j = 0;
					if ( $latest_posts_query->have_posts() ) :
						while ( $latest_posts_query->have_posts() ) :
							$latest_posts_query->the_post();
							?>
							<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
								<?php mts_archive_post(); ?>
							</article>
							<?php
						endwhile;
					endif;

					if ( 0 !== $j ) { // No pagination if there is no posts.
						mts_pagination();
					}
					?>
				</div>	
				<?php
			}
			// Restore original query object.
			$wp_query = $tmp_query; // phpcs:ignore
			// Be kind; rewind.
			wp_reset_postdata();
			?>
		</div>
	</div>
<?php get_footer(); ?>