Created
August 30, 2019 10:39
-
-
Save damiencarbery/c61558ee265174e4c86fe3695cd87650 to your computer and use it in GitHub Desktop.
Instead of a custom loop, use actions and filters to change the output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Reply to post: https://www.facebook.com/groups/genesiswp/permalink/2653424794708701/ | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
//* Remove site footer widgets | |
remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' ); | |
add_filter( 'genesis_post_info', 'dcwd_post_info' ); | |
function dcwd_post_info( $post_info ) { | |
// $post_info = '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]'; | |
return '[post_date]'; | |
} | |
add_action( 'wp_enqueue_scripts', 'dcwd_add_font_awesome_4' ); | |
function dcwd_add_font_awesome_4() { | |
wp_enqueue_style( 'fa4', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' ); | |
} | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'single_posts_body_class' ); | |
function single_posts_body_class( $classes ) { | |
$classes[] = 'custom-single'; | |
return $classes; | |
} | |
add_action( 'genesis_before_loop', 'dcwd_add_article_div' ); | |
function dcwd_add_article_div() { | |
?> | |
<div class="article"></div> | |
<?php | |
} | |
add_action( 'genesis_before_entry', 'dcwd_blogpost_div_and_featured_image' ); | |
function dcwd_blogpost_div_and_featured_image() { | |
?> | |
<div class="blogpost"> | |
<div class="img"> | |
<?php $largeimage = get_field('larger_featured_image'); | |
if( $largeimage ){ ?> | |
<img src="<?php echo $largeimage; ?>" class="aligncenter" alt="<?php the_title(); ?>" /> | |
<?php | |
} else { | |
the_post_thumbnail(); | |
} | |
?></div> | |
<?php | |
} | |
add_action( 'genesis_entry_header', 'dcwd_author_avatar' ); | |
function dcwd_author_avatar() { | |
?> | |
<span class="authorarea"><span class="avatar"><?php echo get_avatar( get_the_author_meta('email'), '60' ); ?></span>By: <?php the_author_posts_link(); ?></span> | |
<?php | |
} | |
add_action( 'genesis_before_entry_content', 'dcwd_title_and_categories' ); | |
function dcwd_title_and_categories() { | |
?> | |
<div class="headingarea"> | |
<h1><?php the_title(); ?></h1> | |
<?php | |
$categories = get_the_category(); | |
if ( ! empty( $categories ) ) { | |
echo '<i class="fa fas fa-angle-double-right"></i><a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>'; | |
} ?> | |
<span class="redline"></span> </div> | |
<?php | |
} | |
add_action( 'genesis_after_entry', 'dcwd_post_navigation' ); | |
function dcwd_post_navigation() { | |
the_post_navigation(); | |
echo '</div>'; // Close <div class="blogpost"> | |
} | |
//* Run the Genesis loop | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment