-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-Homepage.php
139 lines (107 loc) · 4.05 KB
/
template-Homepage.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
135
136
137
138
139
<?php
/**
* Template Name: Berea Homepage
*/
get_header(); ?>
<div id="middlepgbg">
<div id="middle1col">
<div id="middle1col">
<div id="topnav">
<ul>
<li><a href="/admissions">Prospective Students</a></li>
<li><a href="/give-to-berea">Give to Berea</a></li>
<li><a href="http://www.bereacollegealumni.com">Alumni</a></li>
<li><a href="/campus">Community</a></li>
</ul>
</div>
<div id="banner">
<div id="featured" >
<?php echo do_shortcode( "[all_in_one_contentSlider settings_id='2']" ) ?>
</div>
</div>
<div id="hpcontent">
<?php the_content(); ?>
<div id="newsfeatures">
<h2>News & Events</h2>
<div class="lcol">
<div class="content">
<!-- Start feed from BC Spotlight -->
<?php
function catch_that_image($item) {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $item->get_content(), $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}
?>
<?php // Get RSS Feed(s)
include_once('/wp-includes' . '/feed.php');
$rss = fetch_feed('http://www.berea.edu/berea-spotlight/home-page/feed/');
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(1);
$rss_items = $rss->get_items(0, $maxitems);
endif;
?>
<?php
if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<div class="picture"><?php $image = catch_that_image($item); ?>
<img src="<?php echo $image ?>" width="130" alt=""></div>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'style="float:">
<h3><?php echo $item->get_title(); ?></a></h3>
<p><?php echo $item->get_description(); ?></p>
<?php endforeach; ?>
<!-- End feed from BC Spotlight -->
</div>
<div style="clear:both;"></div>
</div>
<div class="rcol">
<!-- Start RSS feed from BCnow -->
<h3><?php _e('Recent News From BCnow:'); ?></h3>
<?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://bcnow.berea.edu/feed/');
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif;
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo esc_url( $item->get_permalink() ); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo esc_html( $item->get_title() ); ?></a>
</li>
<?php endforeach; ?>
</ul>
<!-- Stop RSS feed from BCnow -->
</div>
<div style="clear:both;"></div>
<div class="morenewsftrs">
<ul>
<li class="title">More Stories:</li>
<li><a href="http://bcnow.berea.edu">BCnow</a></li>
<li class="lastitem"><a href="http://192.68.112.220/berea-spotlight/">Berea Spotlight</a></li>
</ul>
</div>
<div style="clear:both"></div>
</div>
<div style="clear:both"></div>
</div>
<?php get_footer(); ?>