wordpress-theme / front-page.php
front-page.php
Raw
<?php get_header(); ?>
    <?php if (have_posts()) {
        while(have_posts()) {
            the_post(); 
        ?>
        <div class="home-info">
            <?php the_content(); ?> 
        </div>
        <?php 
        }
        wp_reset_postdata();
    }
    ?>
        <!--  adding widget section   -->
        <?php
            if(is_active_sidebar('first_widget')) : 
        ?>
            <div id='first_widget'>
                <?php dynamic_sidebar('first_widget'); ?>
            </div>
        <?php endif ?>

        <div class="room-section">
            <?php 
            query_posts('category_name=FrontPageRomms&posts_per_page=1');
                if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post(); 
                        ?>
                        <div>
                            <?php
                                if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                                    $thumbnail_url = get_the_post_thumbnail_url('', 'post-thumbnails');    
                                } 
                            ?>
                            <img alt="" src='<?php echo $thumbnail_url; ?>'>
                        </div>
                        <div>
                        <?php the_content(); 
                            $cat_id = get_cat_ID("Rooms");
                            $category_link = get_category_link($cat_id )
                            ?>
                            <a href="<?php echo esc_url($category_link) ?> " title="Rooms"> Rooms</a>
                        </div>
                        <?php
                    } 
                    wp_reset_postdata();
                } 
            ?>
        </div>

        <div class="room-section suite-section">
            <?php 
            query_posts('category_name=FrontPageSuites&posts_per_page=1');
                if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post(); 
                        ?>
                        <div>
                        <?php the_content(); 
                            $cat_id2 = get_cat_ID("Suites");
                            $category_link2 = get_category_link($cat_id2 )
                        ?>
                        <a href="<?php echo esc_url($category_link2) ?> " title="Suites"> Suites</a>
                        </div>
                        <div>
                            <?php
                                if ( has_post_thumbnail() ) { 
                                    $thumbnail_url2 = get_the_post_thumbnail_url('', 'post-thumbnails');    
                                } 
                            ?>
                            <img alt="" src='<?php echo $thumbnail_url2; ?>'>
                        </div>
                        <?php
                    } 
                    
                } 
                wp_reset_postdata();
            ?>
        </div>
        <div class="service-section">
        <?php 
            query_posts('category_name=services&posts_per_page=3');
                if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post(); 
                        ?>
                        <article>
                            <?php   
                                if( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                                    $thumbnail_url = get_the_post_thumbnail_url('', 'post-thumbnails');  
                                    
                                    ?>
                                    <a href="<?php the_permalink(); ?> "> 
                                    <span><?php the_title(); ?> </span>
                                    </a>
                                    <img  alt ="" src='<?php echo $thumbnail_url; ?>'>
                                    <?php
                                } 
                            ?>
                            
                        </article>
                        <?php
                    } 
                    wp_reset_postdata();
                } 
            ?>
        </div>

        <h1 class="news-heading"> Latest News From Palm Hotel:</h1>
        <div class="news-section">
        <?php 
            query_posts('category_name=NEWS&posts_per_page=2');
                if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post(); 
                        ?>
                        <article >
                            <?php  
                                if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                                    $thumbnail_url = get_the_post_thumbnail_url('', 'post-thumbnails');
                                    ?>
                                    <div class="news-img-wrapper">
                                    <img class="newsImg" src='<?php echo $thumbnail_url; ?>' alt="">
                                    </div>    
                                    <?php
                                } 
                            ?>
                            <br>
                            <div class="news-header"><?php the_title(); ?> </div>
                            <?php the_excerpt(); ?>
                            <br>
                            <br>
                            <a href= "<?php the_permalink(); ?>" >
                                <span > Read more! </span>
                            </a>
                        </article>
                        <?php
                    } 
                    wp_reset_postdata();
                }?>
            </div> 
    <?php
    get_footer();
?>