-
-
Save GaryJones/2cf5e711bee56f11f3f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
add_action( 'genesis_entry_content', 'kat_grid_content', 9 ); | |
/** | |
* Change the number of words in excerpt if in the grid loop and customize READ MORE, add accessibility. | |
*/ | |
function kat_grid_content() { | |
// Make sure we're in the grid loop. | |
if ( ! apply_filters( 'is_genesis_grid_loop', false ) ) { | |
return; | |
} | |
// Change length of teaser. | |
$length = 55; | |
if ( in_array( 'teaser', get_post_class() ) ) { | |
$length = 25; | |
} | |
echo '<p>' . wp_trim_words( get_the_excerpt(), $length ) . '</p>'; | |
// Display more link. | |
printf( | |
'<p class="more-link"><a href="%1$s">%2$s<span class="screen-reader-text"> %3$s %4$s</span></a></p>', | |
esc_url( get_permalink() ), | |
esc_html__( 'Read more', 'your-text-domain' ), | |
esc_html_x( 'about', 'i.e. Read more about A Post Title', 'your-text-domain' ), | |
esc_html( get_the_title() ) | |
); | |
// Remove default content so we don't get both. | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment