Skip to content

Instantly share code, notes, and snippets.

@wpmark
Created December 16, 2015 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmark/1f55055ec175cd74d481 to your computer and use it in GitHub Desktop.
Save wpmark/1f55055ec175cd74d481 to your computer and use it in GitHub Desktop.
Overriding the Markup with the Flexible Featured Post Widget
<?php
/**
* function wpmark_remove_ffpw_output_action()
*
* removes the flexibile featured post widgets output
*/
function wpmark_remove_ffpw_output_action() {
remove_action( 'ffpw_featured_post_output', 'ffpw_featured_post_output', 10, 3 );
}
add_action( 'init', 'wpmark_remove_ffpw_output_action' );
/**
* function wpmark_add_ffpw_widget_output()
*
* creates the markup and output for the flexible featured post widget
*
* @param array $args is the widget args e.g. before_title / after_title
* @param array $instance is the widget settings instance e.g. title, show author etc.
* @param obj $post is the post object of the featured post queried
*/
function wpmark_add_ffpw_widget_output( $args, $instance, $post ) {
echo $args[ 'before_widget' ];
/* if we have a title */
if( $instance[ 'title' ] != '' ) {
echo $args[ 'before_title' ]; echo esc_html( $title ); echo $args[ 'after_title' ];
}
?>
<h2 class="post-title">
<a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>">
<?php echo esc_html( $post->post_title ); ?>
</a>
</h2>
<?php
echo $args[ 'after_widget' ];
}
add_action( 'ffpw_featured_post_output', 'wpmark_add_ffpw_widget_output', 10, 3 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment