-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·88 lines (72 loc) · 2.27 KB
/
index.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
<?php
//this page is used for blogposts
require 'header.php';
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
$offset = 0;
$posts_per_page = 5;
$pages = ceil($published_posts / 5);
$counter = 1;
$pagingArr = array();
while ($counter <= $pages) {
$pagingArr[$counter] = array("active" => "");
$counter++;
}
if (isset($_GET['page'])) {
$currentPageId = intval($_GET['page']);
} else {
$currentPageId = 1;
}
if (!isset($pagingArr[$currentPageId])) {
$currentPageId = 1;
}
$pagingArr[$currentPageId]['active'] = "active";
$offset = ($currentPageId - 1) * $posts_per_page;
$args = array(
'posts_per_page' => $posts_per_page,
'offset' => $offset,
'category' => '',
'category_name' => '',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$posts_array = get_posts($args);
foreach ($posts_array as $k => $v) {
$posts_array[$k]->short_content = get_field("short_content", $v->ID);
$posts_array[$k]->post_day = date("d", strtotime($v->post_date));
$posts_array[$k]->post_month = date("M", strtotime($v->post_date));
$posts_array[$k]->dutch_post_time = date("H:i", strtotime($v->post_date));
$posts_array[$k]->permalink = get_permalink($v->ID);
}
$smarty->assign('posts', $posts_array);
$smarty->assign('paging', $pagingArr);
$postsPageId = get_option('page_for_posts');
$postsPage = get_post($postsPageId);
$page = array(
"site_name" => get_bloginfo('name'),
"site_description" => get_bloginfo('description'),
"permalink" => get_permalink($postsPageId),
"post_name" => $postsPage->post_name,
"title" => $postsPage->post_title,
"content" => "",
"meta_description" => "Posts overview",
"meta_title" => $postsPage->post_title . ' - ' . get_bloginfo('name'),
"featured_image" => false
);
$page["encoded_permalink"] = urlencode($page["permalink"]);
$page["encoded_title"] = urlencode($page["title"]);
$page["encoded_summary"] = urlencode($page["meta_description"]);
$smarty->assign('page', $page);
$smarty->display('posts.tpl');
?>