Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created July 22, 2015 13:05
Show Gist options
  • Save gicolek/f82e6fb5d2313c0cef8d to your computer and use it in GitHub Desktop.
Save gicolek/f82e6fb5d2313c0cef8d to your computer and use it in GitHub Desktop.
ACF Recent Posts Widget before hook
<?php
remove_filter( 'acp_rwp_before', array( 'ACF_Helper', 'af_bf_content_filter' ) );
add_filter( 'acp_rwp_before', 'wp_doin_before_custom_text', 999, 3 );
/**
* @hook acp_rwp_before
*/
function wp_doin_before_custom_text($before, $instance, $id) {
// note that to make usage of all function arguments
// you will need to provide the hook with priority and extra params argument
// say we want to append custom author info to the widget with author CSS class
// after each post before content
if ( $instance['css'] === 'author' ) {
$before .= '<h3>Posted by: ' . get_the_author() . '</h3><hr />';
}
return $before;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment