Created
December 16, 2015 10:12
-
-
Save wpmark/1f55055ec175cd74d481 to your computer and use it in GitHub Desktop.
Overriding the Markup with the Flexible Featured Post Widget
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 | |
/** | |
* 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