Skip to content

Commit f0671c3

Browse files
author
Connor Bär
committed
Bumps version to 1.3.0.
1 parent a87d583 commit f0671c3

File tree

5 files changed

+72
-14
lines changed

5 files changed

+72
-14
lines changed

components/element-standard.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
*
55
* @link https://codex.wordpress.org/Template_Hierarchy
66
*
7-
* @package UWC_Website
7+
* @package UWCde_Website
88
*/
99

10-
?>
11-
12-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'category-post' ); ?>>
10+
?><article id="post-<?php the_ID(); ?>" <?php post_class( 'category-post' ); ?>>
1311
<?php if ( get_field( 'feed_image' ) ) :
1412
$image = get_field( 'feed_image' );
15-
$size = 'medium';
16-
$url = $image['sizes'][ $size ];
13+
$size = 'medium';
14+
$url = $image['sizes'][ $size ];
1715
?>
1816
<a class="category-image" style="background-image: url(<?php echo esc_url( $url ); ?>)" href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"></a>
1917
<?php elseif ( has_post_thumbnail() ) : ?>
@@ -32,7 +30,7 @@
3230
<?php if ( $tags = get_the_tags() ) {
3331
echo '<p class="category-tags">';
3432
foreach ( $tags as $tag ) {
35-
$sep = ( end( $tags ) === $tag ) ? '' : ', ';
33+
$sep = (end( $tags ) === $tag) ? '' : ', ';
3634
echo '<a href="' . esc_url( get_term_link( $tag, $tag->taxonomy ) ) . '">#' . esc_html( $tag->name ) . '</a>' . esc_html( $sep );
3735
}
3836
echo '</p>';

components/module-newsfeed.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Element to output the Newsfeed preview on section pages.
4+
* Gets the 4 most recent posts belonging to the selected categories.
5+
* Outputs them with markup if at least one category is set and a minimum of 4 posts exist.
6+
*
7+
* @link https://codex.wordpress.org/Template_Hierarchy
8+
*
9+
* @package UWCde_Website
10+
*/
11+
12+
$taxonomies = get_field( 'newsfeed' );
13+
14+
$posts = get_posts(array(
15+
'posts_per_page' => 4,
16+
'category' => $taxonomies,
17+
'orderby' => 'date',
18+
'order' => 'DESC',
19+
'post_status' => 'publish',
20+
));
21+
$count = count( $posts );
22+
23+
if ( $taxonomies && $count >= 4 ) {
24+
echo '<section class="section-newsfeed">';
25+
$index = 1;
26+
foreach ( $posts as $post ) {
27+
$categories = array();
28+
29+
foreach ( $taxonomies as $taxonomy ) {
30+
if ( in_category( $taxonomy, $post->ID ) ) {
31+
array_push( $categories, $taxonomy );
32+
}
33+
}
34+
35+
if ( get_field( 'feed_image', $post->ID ) ) {
36+
$image = get_field( 'feed_image', $post->ID );
37+
$size = 'medium';
38+
$image_url = $image['sizes'][ $size ];
39+
40+
echo '<article class="section-post post-' . intval( $index ) . ' -thumbnail"><div class="section-image" style="background-image: url(';
41+
echo esc_url( $image_url );
42+
echo ')"></div>';
43+
} elseif ( has_post_thumbnail( $post->ID ) ) {
44+
$featured = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
45+
$featured_url = $featured[0];
46+
47+
echo '<article class="section-post post-' . intval( $index ) . ' -thumbnail"><div class="section-image" style="background-image: url(';
48+
echo esc_url( $featured_url );
49+
echo ')"></div>';
50+
} else {
51+
echo '<article class="section-post post-' . intval( $index ) . ' -no-thumbnail">';
52+
}
53+
echo '<div class="section-wrapper">';
54+
foreach ( $categories as $category ) {
55+
echo '<a href="' . esc_url( get_category_link( $category ) ) . '" class="section-category">' . esc_html( get_cat_name( $category ) ) . '</a> ';
56+
}
57+
echo '<a href="' . esc_url( get_permalink( $post->ID ) ) . '"><h2 class="section-headline">' . get_the_title( $post->ID ) . '</h2><h4 class="section-date">' . get_the_date( '', $post->ID ) . '</h4></a></div></article>';
58+
++$index;
59+
}
60+
echo '</section>';
61+
}

components/site-logo.php

Lines changed: 3 additions & 4 deletions
Large diffs are not rendered by default.

screenshot.jpg

100755100644
2.76 KB
Loading

style.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
@charset "UTF-8";/*!
1+
/*!
22
Theme Name: UWCde Website
33
Theme URI: https://github.com/uwc/uwcde-website
4-
Author: Connor Bär
4+
Author: Connor Baer
55
Author URI: http://connorbaer.io
66
Description: An open-source WordPress child theme for UWC Germany.
77
Template: uwc-website
8-
Version: 1.2.1
8+
Version: 1.3.0
99
License: MIT
1010
License URI: https://opensource.org/licenses/MIT
1111
Tags: custom-menu, editor-style, featured-image-header, featured-images, post-formats, sticky-post, theme-options, education, translation-ready

0 commit comments

Comments
 (0)