mirror of
https://github.com/ascribe/wp-theme
synced 2024-12-22 17:23:55 +01:00
quick, hacky way to fall back to latest posts
This commit is contained in:
parent
d1793240bb
commit
6d89ed96d2
@ -356,21 +356,41 @@ class Subtemplate {
|
|||||||
//
|
//
|
||||||
public function blogFeatures() {
|
public function blogFeatures() {
|
||||||
|
|
||||||
$blogFeatures = '';
|
$blogFeatures = '';
|
||||||
$subtemplateTitle = get_sub_field('section_title');
|
$subtemplateTitle = get_sub_field('section_title');
|
||||||
|
$blogPage = get_page_by_title('Blog');
|
||||||
|
$blogUrl = get_permalink($blogPage->ID);
|
||||||
|
|
||||||
if (have_rows('blog_features','option')) {
|
if (have_rows('blog_features', 'option')) {
|
||||||
while (have_rows('blog_features','option')) {
|
while (have_rows('blog_features', 'option')) {
|
||||||
the_row();
|
the_row();
|
||||||
|
$feature = get_sub_field('post');
|
||||||
|
$postTitle = $feature->post_title;
|
||||||
|
$url = get_permalink($feature->ID);
|
||||||
|
$content = substr($feature->post_content, 0, 144) . '...';
|
||||||
|
$date = date('F Y', strtotime($feature->post_date));
|
||||||
|
$image = wp_get_attachment_image_src(get_post_thumbnail_id($feature->ID),'blog-feature-crop')[0];
|
||||||
|
|
||||||
$feature = get_sub_field('post');
|
$blogFeatures .= "<div class='grid__col'>
|
||||||
$postTitle = $feature->post_title;
|
<a href='{$url}'>
|
||||||
$url = get_permalink($feature->ID);
|
<article class='featured'>
|
||||||
$content = substr($feature->post_content, 0, 144) . '...';
|
<img class='featured__image' src='{$image}' alt='{$postTitle} Image'>
|
||||||
$date = date('F Y', strtotime($feature->post_date));
|
<h1 class='featured__title'>{$postTitle}</h1>
|
||||||
$image = wp_get_attachment_image_src(get_post_thumbnail_id($feature->ID),'blog-feature-crop')[0];
|
</article>
|
||||||
$blogPage = get_page_by_title('Blog');
|
</a>
|
||||||
$blogUrl = get_permalink($blogPage->ID);
|
</div>";
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$latestPosts = wp_get_recent_posts(array( 'numberposts' => '3' ));
|
||||||
|
|
||||||
|
foreach( $latestPosts as $latest ) {
|
||||||
|
$postTitle = $latest['post_title'];
|
||||||
|
$url = get_permalink($latest['ID']);
|
||||||
|
$content = substr($latest['post_content'], 0, 144) . '...';
|
||||||
|
$date = date('F Y', strtotime($latest['post_date']));
|
||||||
|
$image = wp_get_attachment_image_src(get_post_thumbnail_id($latest['ID']),'blog-feature-crop')[0];
|
||||||
|
|
||||||
$blogFeatures .= "<div class='grid__col'>
|
$blogFeatures .= "<div class='grid__col'>
|
||||||
<a href='{$url}'>
|
<a href='{$url}'>
|
||||||
|
Loading…
Reference in New Issue
Block a user