This repository was archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
73 lines (62 loc) · 1.93 KB
/
index.php
File metadata and controls
73 lines (62 loc) · 1.93 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
66
67
68
69
70
71
72
73
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package NotePress
*/
get_header();
get_sidebar(); ?>
<main id="main">
<?php
$args = [
'post_type' => 'post'
];
$lists = get_posts( $args );
foreach ($lists as $l) {
echo '<div class="main-list">';
echo '<h3 class="main-list-title">' . $l -> post_title . '</h3>';
echo '<h5 class="main-list-date">' . substr($l -> post_date, 0, 10) . '</h5>';
echo '<h4 class="main-list-content">' . wp_trim_words( $l-> post_content, 16, ' ...' ) . '</h4>';
echo '</div>';
}
?>
</main>
</section>
<aside id="one">
<?php
if ( have_posts() ) {
$args = [
'numberposts' => 1,
'post_type' => 'post'
];
$recent = wp_get_recent_posts($args);
//var_dump($recent[0]);
$categories = wp_get_post_categories($recent[0]['ID']);
$tags = wp_get_post_tags($recent[0]['ID']);
echo '<h1>' . $recent[0]['post_title'] . '</h1>';
foreach ($categories as $c) {
$note = get_category($c);
echo '<h5 class="one-book">' . $note -> name . '</h5>';
}
foreach ($tags as $t) {
echo '<h5 class="one-tag">' . $t -> name . '</h5>';
}
echo '<h5 id="one-time">' . substr($recent[0][post_date], 0, 10) . '</h5>';
echo '<a id="one-open" href="'. $recent[0][guid] .'">' . OPEN . '</a>';
echo '<article id="one-content">' . wpautop($recent[0][post_content]) . '</article>';
}
?>
</aside>
<?php
get_footer();
foreach($lists as $l) {
$l->post_content = wpautop( $l->post_content );
}
echo '<script id="data-list" type="application/json">' . json_encode($lists) .'</script>';