-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfront-page.php
134 lines (113 loc) · 6.38 KB
/
front-page.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!--
This file will render whatever page you set as your home page.
By default the home page is a list of all the posts but you can change it
to a static page through the customize section and the home page settings tab.
-->
<!--
get_header('front') would then look for header-front.php rather than header.php
https://codex.wordpress.org/Function_Reference/get_header
-->
<?php
get_header('front');
?>
<div class="container">
<div class="row mb-5 mt-5">
<div class="card-deck">
<?php for ($i=1; $i <= 2 ; $i++): ?>
<?php $featuredPostID = get_theme_mod('featured_post_'.$i.'_setting'); ?>
<?php if($featuredPostID): ?>
<?php
$args = array(
'p' => $featuredPostID
);
$featuredPost = new WP_Query($args);
?>
<?php if( $featuredPost->have_posts() ): ?>
<?php while($featuredPost->have_posts()): $featuredPost->the_post();?>
<div class="card col-6">
<h3><?php the_title(); ?></h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<button type="button" name="button" class="btn btn-secondary mb-2">Go to Post</button>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php endif; ?>
<?php endfor; ?>
</div>
</div>
<div class="row">
<div class="col">
<h1>Home Page</h1>
</div>
</div>
<div class="row">
<div class="col">
<?php if(have_posts()): ?>
<div class="card-columns">
<?php while(have_posts()): the_post();?>
<!--
What we are going to do is render out a different card
depending on what post format our post is.
What it is going to look for is a file called content-{postformat}.php.
If it cant't find that file, it will look for content.php.
It will then paste the contents of that file into this location.
-->
<?php get_template_part('content', get_post_format()); ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
<?php
$total = wp_count_posts()->publish;
$canShow = get_option('posts_per_page');
?>
<?php if($total > $canShow): ?>
<div class="col-12">
<hr>
<?php
$paginate_args = array(
'type' => 'array'
);
$all_pages = paginate_links($paginate_args);
?>
<nav>
<ul class="pagination">
<?php foreach($all_pages as $page): ?>
<li class="page-item">
<?php echo str_replace('page-numbers', 'page-link', $page); ?>
</li>
<?php endforeach; ?>
</ul>
</nav>
<button type="button" name="button" class="btn btn-primary btn-block show-more">Show More</button>
</div>
<?php endif; ?>
<!--
Our users don't actually need to include widgets on the theme.
So we need to make sure we wrap it is around an if statement
and if there aren't any widgets, then the design still needs to look good.
In our theme. If there are widgets inside the front_page_sidebar then we want our theme
to use 9 and 3 columns. Otherwise we want the main posts to take up the whole 12.
is_active_sidebar() needs the ID of the registered sidebar. So this must match
what you wrote in functions.php
-->
<?php if( is_active_sidebar('front_page_sidebar') ): ?>
<div class="col-3">
<div id="frontSidebar">
<!--
To get the sidebar to actually show all the widgets, then say dynamic_sidebar(id)
This will then echo out all the widgets which you have specified in the widgets section.
By default they will be echoed out as li's but if you change the befores and afters then
it would use those instead.
The widgets will use default styles so they won't look good by default.
If you are allowing widgets, you will have to style them yourself in your css.
There is a way on only allowing specific widgets on your site which also might be useful
if you don't want to style every single widget.
-->
<?php dynamic_sidebar('front_page_sidebar'); ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>