Skip to content

Commit

Permalink
new: add featured image on WPPedia pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bfiessinger committed May 24, 2021
1 parent e6af029 commit 015a8a8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions source/scss/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
margin-left:auto;
margin-right:auto;
}
}

/**
* Loop
*/
.wppedia-page {
.wppedia-thumbnail-wrapper {
float: left;
clear: left;
margin-right: 1em;
}
.pagination {
ul {
list-style-type: none;
Expand All @@ -19,9 +30,6 @@
}
}

/**
* Loop
*/
.wppedia-char-section-indentifier {
display: inline-flex;
align-items: center;
Expand Down
16 changes: 12 additions & 4 deletions template-hooks/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,27 @@
* Singular page hooks
*/
add_action( 'wppedia_before_single_post', 'wppedia_entry_content_start', 10 );
add_action( 'wppedia_single_post', 'wppedia_single_title', 10 );
add_action( 'wppedia_single_post', 'wppedia_single_content', 20 );
add_action( 'wppedia_single_post', 'wppedia_single_link_pages', 30 );

add_action( 'wppedia_single_post', 'wppedia_single_featured_image', 10 );
add_action( 'wppedia_single_post', 'wppedia_single_title', 20 );
add_action( 'wppedia_single_post', 'wppedia_single_content', 30 );
add_action( 'wppedia_single_post', 'wppedia_single_link_pages', 40 );

add_action( 'wppedia_after_single_post', 'wppedia_entry_content_end', 10 );

/**
* Archive page hooks
*/
add_action( 'wppedia_before_post_loop', 'wppedia_postlist_wrapper_start', 10 );
add_action( 'wppedia_before_loop_item_title', 'wppedia_loop_postlink_open', 10 );

add_action( 'wppedia_before_loop_item_title', 'wppedia_loop_featured_image', 10 );
add_action( 'wppedia_before_loop_item_title', 'wppedia_loop_postlink_open', 20 );

add_action( 'wppedia_loop_item_title', 'wppedia_loop_item_title', 10 );

add_action( 'wppedia_after_loop_item_title', 'wppedia_loop_excerpt', 20 );
add_action( 'wppedia_after_loop_item_title', 'wppedia_loop_postlink_close', 10 );

add_action( 'wppedia_after_post_loop', 'wppedia_postlist_wrapper_end', 10 );

add_action( 'wppedia_after_main_content', 'wppedia_posts_pagination', 10 );
Expand Down
15 changes: 15 additions & 0 deletions template-hooks/loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ function wppedia_loop_item_title() {
}
}

/**
* Loop Featured Image
*
* @since 1.1.3
*/
if ( ! function_exists( 'wppedia_loop_featured_image' ) ) {
function wppedia_loop_featured_image() {
if (has_post_thumbnail()) {
echo '<div class="wppedia-thumbnail-wrapper">';
the_post_thumbnail('thumbnail', ['class' => 'wppedia-post-thumbnail']);
echo '</div>';
}
}
}

/**
* Loop excerpt
*
Expand Down
40 changes: 40 additions & 0 deletions template-hooks/singular.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
<?php

/**
* Starting tag for entry content wrapper
*
* @since 1.0.0
*/
if (!function_exists('wppedia_entry_content_start')) {
function wppedia_entry_content_start() { ?>
<div class="entry-content">
<?php }
}

/**
* Closing tag for entry content wrapper
*
* @since 1.0.0
*/
if (!function_exists('wppedia_entry_content_end')) {
function wppedia_entry_content_end() { ?>
</div>
<?php }
}

/**
* Singular Featured Image
*
* @since 1.1.3
*/
if ( ! function_exists( 'wppedia_single_featured_image' ) ) {
function wppedia_single_featured_image() {
if (has_post_thumbnail()) {
echo '<div class="wppedia-featured-image-wrapper">';
the_post_thumbnail('post-thumbnail', ['class' => 'wppedia-post-thumbnail']);
echo '</div>';
}
}
}

/**
* Singular title
*
* @since 1.0.0
*/
if (!function_exists('wppedia_single_title')) {
function wppedia_single_title() {
the_title('<h1 class="wppedia-title entry-title">', '</h1>');
}
}

/**
* Singular content
*
* @since 1.0.0
*/
if (!function_exists('wppedia_single_content')) {
function wppedia_single_content() {
the_content(
Expand All @@ -37,6 +72,11 @@ function wppedia_single_content() {
}
}

/**
* Link pages
*
* @since 1.0.0
*/
if (!function_exists('wppedia_single_link_pages')) {
function wppedia_single_link_pages() {
wp_link_pages(
Expand Down

0 comments on commit 015a8a8

Please sign in to comment.