• First off, great work on this awesome plugin!

    I’d like to filter the HTML output of the recent post listing… More precisely, I’d like to remove the <h3> from the post title and enclose both the featured thumbnail and the post title in one <a> element.

    I’m struggling with using the rpwe_markup filter to implement my changes.

    Would it be possible to provide an example of that filter in use?

    Many thanks!

    https://www.ads-software.com/plugins/recent-posts-widget-extended/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’d like to see an example of how to use this filter as well.

    I’ve tried to copy code from the include/functions.php and it seems to reset the arguments of the widget to the default arguments.

    From what I gather, it seems like I have to be very “hacky” about getting this to work and that’s a bit much for a filter.

    OK, I think I see the issue.

    In the plugin’s include/functions.php line 200 apply_filters does not have any variables to be passed.

    return wp_kses_post( $args['before'] ) . apply_filters( 'rpwe_markup', $html ) . wp_kses_post( $args['after'] );

    It should be:

    return wp_kses_post( $args['before'] ) . apply_filters( 'rpwe_markup', $html, $args ) . wp_kses_post( $args['after'] );

    That way the args could be passed for the proper html to be filtered out. So your callback would look like this:

    add_filter('rpwe_markup','your_filter_callback', 10, 2);
    
    function your_filter_callback($html,$args){
           $posts = rpwe_get_posts( $args );
    	if ( $posts->have_posts() ) :
    
              $html = '<ul>'; //open post wrapper
    
          while ( $posts->have_posts() ) : $posts->the_post();
    
                //Your post loop
                $html .= '<li></li>';
    
          endwhile;
    
           $html .= '</ul >' //close post wrapper
         endif;
    
       return $html;
    }

    I say just copy what’s on the includes/functions.php from 105 to 217 and alter as you wish.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Example of rpwe_markup filter’ is closed to new replies.