Created
January 26, 2016 22:12
-
-
Save lorinrivers/5cbb6cc8efe3560c5a24 to your computer and use it in GitHub Desktop.
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 | |
// Template Name: Feature | |
// Adds Page Title | |
add_action( 'genesis_before_content', 'genesis_do_post_title' ); | |
// Adds Page Content | |
add_action( 'genesis_before_loop', 'st_do_feature_content' ); | |
function st_do_feature_content() { | |
echo '<div class="entry-content entry-feature" itemprop="text">'; | |
echo '<p class="feature-page">' . get_post()->post_content . '</p>'; | |
echo '</div>'; | |
} | |
add_filter( 'excerpt_more', 'feature_read_more_link' ); | |
add_filter( 'get_the_content_more_link', 'feature_read_more_link' ); | |
add_filter( 'the_content_more_link', 'feature_read_more_link' ); | |
/** | |
* Custom Read More link. | |
* | |
* @author Wes Straham | |
* @since 1.0.0 | |
*/ | |
function feature_read_more_link() { | |
return '<p class="learn-more"><a class="more-link" href="' . get_permalink() . '" rel="nofollow">Learn More</a></p>'; | |
} | |
/** Replace the standard loop with our custom loop */ | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'child_do_custom_loop' ); | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); | |
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); | |
add_action( 'genesis_entry_content', 'st_feature_detail', 9 ); // For Genesis 2.x | |
// add_action( 'genesis_before_footer', 'st_do_testimonial', 9 ) | |
add_action( 'genesis_entry_header', 'featured_post_image', 0 ); | |
function featured_post_image() { | |
the_post_thumbnail('feature-thumbnail'); //you can use medium, large or a custom size | |
} | |
function child_do_custom_loop() { | |
global $paged; // current paginated page | |
global $query_args; // grab the current wp_query() args | |
$args = array( | |
'post_type' => 'feature', | |
'category_name' => get_post_meta( get_the_ID(), '_ST_category', true ), // include posts from this category | |
'paged' => $paged, // respect pagination | |
); | |
add_filter( 'genesis_attr_entry', 'st_feature_entry'); | |
function st_feature_entry($attributes) { | |
global $wp_query; | |
// add original plus extra CSS classes | |
$attributes['class'] .= ' article_' . ($wp_query->current_post + 1); | |
// return the attributes | |
return $attributes; | |
} | |
genesis_custom_loop( wp_parse_args($query_args, $args) ); | |
// wp_reset_postdata(); | |
} | |
function st_feature_detail() { | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); // For Genesis 2.x | |
echo '<p class="feature-detail-excerpt">' . get_the_excerpt() . '</p>'; | |
echo feature_read_more_link(); | |
} | |
// function st_do_testimonial() { | |
// // echo get_post_meta( get_the_ID(), '_ST_testimonial', true ); | |
// // echo '[handsometestimonial id="146"]'; | |
// global $wp_query; // grab the current wp_query() args | |
// $post_id = $wp_query->get_queried_object_id(); | |
// echo $post_id; | |
// } | |
// | |
// function gt_get_the_ID() { | |
// if ( in_the_loop() ) { | |
// $post_id = get_the_ID(); | |
// } else { | |
// /** @var $wp_query wp_query */ | |
// global $wp_query; | |
// $post_id = $wp_query->get_queried_object_id(); | |
// } | |
// return $post_id; | |
// } | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment