I'm trying to create a wp_query to limit posts on a category page to 5 per page. However, this causes a syntax error:
PHP Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in /path/to/file/category.php on line 70
Line 70 is the end of the file.
category.php:
<?php get_header(); ?>
<div class="container-fluid">
<div class="row bg-info p-5">
<div class="col d-none d-lg-block">
</div>
<div class="col">
<?php
// Check if there are any posts to display
if ( have_posts() ) : ?>
<header class="archive-header">
<h1 class="archive-title text-light"><?php single_cat_title( '', true ); ?> posts</h1>
<?php
// Display optional category description
if ( category_description() ) : ?>
<div class="archive-meta text-light"><?php echo category_description(); ?></div>
<?php endif; ?>
</header>
</div>
<div class="col d-none d-lg-block">
</div>
</div>
</div>
<section class="blog pt-5 mt-5">
<div class="container">
<?php
// The Loop
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$args = array(
'posts_per_page' => 5
);
// Variable to call WP_Query.
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
// Start the Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
the_title();
the_excerpt();
// End the Loop
endwhile;
else:
// If no posts match this query, output this text.
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
wp_reset_postdata();
?>
</div>
</section>
<div class="container-fluid">
<div class="row bg-light p-5">
<div class="col d-none d-lg-block">
</div>
<div class="col text-dark">
<p class="text-center">
I hope you enjoyed this list of posts and now have some inspiration for your next Smart Home Automation journey. Remember that in order to make a great Smart Home you'll need to plan ahead, so head on over to our <a href="https://www.smarthomebit.com/top-tips-for-smart-home-beginners/">complete beginners guide</a> or our free downloadable to-buy list <a href="https://www.smarthomebit.com/subscribe/">here</a> to find yourself some amazing gadgets. Check out our gear review library here for more information on the best home automation gear. Once you have all of that, just come back here, good luck!
</p>
</div>
<div class="col d-none d-lg-block">
</div>
</div>
</div>
<?php get_footer(); ?>
includes.php
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900&display=swap" rel="stylesheet">
<!--<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/assets/bootstrap-4.3.1-dist/css/bootstrap.min.css">-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous" async>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css">
<link href="<?php echo get_stylesheet_directory_uri(); ?>/assets/font-awesome/css/all.css" rel="stylesheet"> <!--load all styles -->
<?php include 'shortcodes.php'; ?>
Header.php:
<!DOCTYPE html>
<?php wp_head(); ?>
<?php include 'includes.php'; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<nav class="navbar sticky-top navbar-expand-md navbar-light bg-light text-info" role="navigation">
<div class="container">
<a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php if ( has_custom_logo() ) : ?>
<div class="site-logo img-fluid custom-logo-link"><?php the_custom_logo(); ?></div>
<?php endif; ?>
</a>
<!-- Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
?>
</div>
</nav>
</head>
<html lang="en">
Footer.php
<?php
if( get_theme_mod('social-media-display') === 'Yes') {
$twittertext = get_theme_mod('social-media-twitter-text');
$facebooktext = get_theme_mod('social-media-facebook-text');
$pinteresttext = get_theme_mod('social-media-pinterest-text');
$youtubetext = get_theme_mod('social-media-youtube-text');
$footerctaheader = get_theme_mod('footer-cta-text');
$footercta = get_theme_mod('footer-cta-text');
}
?>
<?php if ( ! is_home() && ! is_front_page() ) : ?>
<?php if( get_theme_mod('footer-cta-display') === 'Yes') { ?>
<!-- eBook download -->
<div class="container-fluid p-4 mt-3" style="background-color: #2D3C83;">
<div class="container">
<div class="row">
<h1 class="elementor-heading-title text-white elementor-size-xxl">Want to get more out of your Smart Home?</h1>
<div class="elementor-element elementor-element-a4adc31 elementor-widget elementor-widget-text-editor">
<div class="elementor-widget-container">
<div class="elementor-text-editor elementor-clearfix"><h2 style="text-align: center;"><span style="color: #ffffff;">Get Started Today with my 5-Day Smart Home Bootcamp!</span></h2></div>
</div>
</div>
</div>
<div class="row">
<?php echo $footercta; ?>
</div>
</div>
</div>
<?php } ?>
<?php endif; ?>
<footer class="footer">
<div class="container pt-4">
<div class="row text-white">
<?php
if(is_active_sidebar('footer-sidebar-1')){
echo '<div class="col-sm">';
dynamic_sidebar('footer-sidebar-1');
echo '</div>';
}
if(is_active_sidebar('footer-sidebar-2')){
echo '<div class="col-sm text-white">';
dynamic_sidebar('footer-sidebar-2');
echo '</div>';
}
if(is_active_sidebar('footer-sidebar-3')){
echo '<div class="col-sm">';
dynamic_sidebar('footer-sidebar-3');
echo '</div>';
}
if(is_active_sidebar('footer-sidebar-4')){
echo '<div class="col-sm">';
dynamic_sidebar('footer-sidebar-4');
echo '</div>';
}
if(is_active_sidebar('footer-sidebar-5')){
echo '<div class="col-sm">';
dynamic_sidebar('footer-sidebar-5');
echo '</div>';
}
?>
</div>
</div>
<div class="container">
<div class="row py-4 text-white text-center">
<div class="col-sm">
© 2019-<?php echo date("Y"); ?> KentWebSpecialists.com
</div>
<div class="col-sm">
<a class="px-1" href="/sitemap_index.xml">Sitemap</a> | <a class="px-1" href="/privacy-policy">Privacy Policy</a> | <a class="px-1" href="#">Disclaimer</a>
</div>
<?php if( get_theme_mod('social-media-display') === 'Yes') { ?>
<div class="col-sm vcenter">
<ul class="socialmedia">
<?php if($twittertext != '') {?><a href="<?php echo $twittertext; ?>"><li><i class="fab fa-1x fa-twitter"></i></li></a><?php }?>
<?php if($facebooktext != '') {?><a href="<?php echo $facebooktext; ?>"><li><i class="fab fa-1x fa-facebook"></i></li></a><?php }?>
<?php if($pinteresttext != '') {?><a href="<?php echo $pinteresttext; ?>"><li><i class="fab fa-1x fa-pinterest"></i></li></a><?php }?>
<?php if($youtubetext != '') {?><a href="<?php echo $youtubetext; ?>"><li><i class="fab fa-1x fa-youtube"></i></li></a><?php }?>
</ul>
</div>
<?php } ?>
<div class="col"> Website created by <a rel="nofollow" href="https://kentwebspecialists.co.uk/"> KentWebSpecialists</a></div>
</div>
</div>
</footer>
<!-- TrustBox script -->
<script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" async></script>
<!-- End TrustBox script -->
<script src="<?php echo get_stylesheet_directory_uri(); ?>/assets/js/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous" async></script>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/assets/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous" async></script>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/dist/js/app.min.js" charset="utf-8" async></script>
<?php wp_footer(); ?>
</body>
</html>