-
-
Save MatRouault/cc754204b0b0c62d1dc97dd4a2c53f64 to your computer and use it in GitHub Desktop.
Beans: split post image/content in two columns.
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 | |
// Do not include the opening php tag if it is already included in your file. | |
add_action( 'wp', 'beans_child_setup_document' ); | |
function beans_child_setup_document() { | |
// Only apply to non-singular layouts. | |
if ( !is_singular() ) { | |
// Remove tags and categories. | |
beans_remove_action( 'beans_post_meta_categories' ); | |
beans_remove_action( 'beans_post_meta_tags' ); | |
// Add post grid attributes. | |
beans_add_attribute( 'beans_post', 'class', 'uk-grid uk-grid-width-medium-1-2' ); | |
beans_add_attribute( 'beans_post', 'data-uk-grid-margin', '' ); | |
// Adjust post title. | |
beans_add_attribute( 'beans_post_title', 'class', 'uk-h2 uk-margin-small-bottom' ); | |
// Adjust image and move it before the beans_child_post_content wrap. | |
beans_add_attribute( 'beans_post_image', 'class', 'uk-margin-bottom-remove' ); | |
beans_modify_action_hook( 'beans_post_image', 'beans_child_post_content_before_markup' ); | |
// Add button class to read more link. | |
beans_add_attribute( 'beans_post_more_link', 'class', 'uk-button uk-button-primary' ); | |
// Wrap beans post content. | |
beans_wrap_inner_markup( 'beans_post', 'beans_child_post_content', 'div' ); | |
} | |
} | |
add_filter( 'the_content', 'beans_child_troncate_post_content' ); | |
function beans_child_troncate_post_content( $content ) { | |
// Only apply to non-singular layouts. | |
if ( !is_singular() ) | |
return '<p>' . wp_trim_words( wp_strip_all_tags( $content, true ), 50, '...' ) . '</p>'; | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment