Skip to main content
4 of 10
update formatting

Wordpress single post content class customization with if-else function

I have the following code, which displays the content for my custom page template "landingpage.php" and for single posts. The site is based on Bootstrap 4.

<?php if(is_page_template( 'landingpage.php' )): ?>

    <div id="content" class="site-content">
        <div class="container-fluid">
            <div class="row">

        <?php elseif (is_single()): ?>

    <div id="content" class="site-content pt-4">
        <div class="container-fluid">
            <div class="row">

        <?php else: ?>

    <div id="content" class="site-content">
        <div class="container">
            <div class="row">
<?php endif; ?>

I'm wondering if there's a more elegant/shorter code to do this?