[PATCH] Custom widget frontends
-
Love your plugin, works a treat.
We wanted to use a slightly differen widget front end HTML structure than what your plugin provides, so I added a small (backwards compatable) patch to support this.
In /custom-post-widget/post-widget.php custom_post_widget::widget() change
$content = $content_post->post_content; if ( !$apply_content_filters ) { // Don't apply the content filter if checkbox selected
to
$content = $content_post->post_content; // Display custom widget frontend if ( $located = locate_template( 'custom-post-widget.php' ) ) { require $located; return; } if ( !$apply_content_filters ) { // Don't apply the content filter if checkbox selected
Example usage:
Add custom-post-widget.php to your theme folder. Copy the rest of the function into the file with any modifications you want to make:
<?php if ( !$apply_content_filters ) { // Don't apply the content filter if checkbox selected $content = apply_filters( 'the_content', $content); } echo $before_widget; if ( $show_custom_post_title ) { echo $before_title; echo apply_filters( 'widget_title',$content_post->post_title); if ( $show_featured_image ) { echo get_the_post_thumbnail( $content_post -> ID ); } echo $after_title; // This is the line that displays the title (only if show title is set) } echo do_shortcode( $content ); // This is where the actual content of the custom post is being displayed echo $after_widget;
In the example above I moved the post thumbnail to before the closing HTML tag. It’s a small example but it shows how easily a post structure could be modified using this method.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[PATCH] Custom widget frontends’ is closed to new replies.