-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredesign-news-featured.php
63 lines (50 loc) · 1.8 KB
/
redesign-news-featured.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
<?php
require_once("../wp-load.php");
/*ini_set('display_errors',1);
error_reporting(E_ALL);*/
class Homepage_News {
public function __construct() {
echo $this-> get_latest_news_stories_ps();
}
private function get_latest_news_stories_ps() {
// Returns posts as arrays instead of get_posts' objects
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 4,
'category' => 10,
'post_status' => 'publish',
'meta_key' => '_thumbnail_id'
));
/*
* Set incrementer
*/
$i = 0;
$news_string = '';
foreach($recent_posts as $post) {
if ($i < 1) {
$news_string .= '<a href="' . get_permalink($post['ID']) . '">
<div class="row">
<div class="columns">
<figure>' . get_the_post_thumbnail( $post['ID'], 'thumbnail') . '</figure>
<p>' . $post['post_title'] . '</p>
</div>
</div>
</a>';
}
else {
$news_string .= '<a href = "' . get_permalink($post['ID']) . '">
<div class = "row">
<div class = "columns medium-12 large-4">
<figure>' . get_the_post_thumbnail( $post['ID'], 'thumbnail') . '</figure>
</div>
<div class = "columns medium-12 large-8">
<p>' . $post['post_title'] . '</p>
</div>
</div>
</a>';
}
$i++;
}
return $news_string;
}
}
New Homepage_News();