-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-home.php
More file actions
65 lines (59 loc) · 2.27 KB
/
page-home.php
File metadata and controls
65 lines (59 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
Template Name: Home Template
*/
?>
<?php get_header(); ?>
<div id="main" class="site-main home-page">
<div id="content" class="site-content template-page" role="main">
<?php
/* The Main loop */ ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="top-intro">
<a href="#" class="logo-home"><img src="<?php bloginfo('template_directory'); ?>/images/logo-home.png" alt="<?php the_title(); ?>"></a>
<div class="entry-content">
<?php
$book_now = get_post_meta( $post->ID, 'book_now', true );
if ( $book_now ) {
echo '<a href="'.$book_now.'" class="button light">'. __( 'Book Now', 'twentyfifteen' ) .'</a>';
} else {
}; ?>
<?php the_content(''); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
<?php
/* Query for 4 featured post */
$featured_query = new WP_Query( array( 'category_name' => 'featured', 'posts_per_page' => 4, 'order' => 'DESC' ) ); ?>
<?php if ( $featured_query->have_posts() ) : ?>
<?php $counter = 0; // postcounter ?>
<ul class="featured-intro">
<?php while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>
<?php $counter++; // postcounter + 1 ?>
<?php
$featured_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
<li style="background-image: url(<?php echo $featured_image; ?>);" class="postcounter-<?php echo $counter; ?>">
<div class="entry-content">
<div class="inner">
<?php the_title( '<h2>', '</h2>' ); ?>
<?php the_content(''); ?>
<?php
$book_now = get_post_meta( $post->ID, 'book_now', true );
if ( $book_now ) {
echo '<a href="'.$book_now.'" class="button light">'. __( 'Book Now', 'twentyfifteen' ) .'</a>';
} else { // button not showing
}; ?>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php else: endif; ?>
</div><!-- #content -->
</div><!-- #main -->