Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 23, 2019 17:00
Show Gist options
  • Save billerickson/c92b742450b20a53c09d8b8277e211e2 to your computer and use it in GitHub Desktop.
Save billerickson/c92b742450b20a53c09d8b8277e211e2 to your computer and use it in GitHub Desktop.
<?php
/**
* Display Posts, span wrapper open
* @see https://displayposts.com/2019/01/23/display-inline-link-with-most-recent-post/
*/
function be_dps_span_wrapper_open( $wrapper, $atts ) {
if( !empty( $atts['wrapper'] ) && 'span' == $atts['wrapper'] )
$wrapper = '<span class="display-posts-listing">';
return $wrapper;
}
add_filter( 'display_posts_shortcode_wrapper_open', 'be_dps_span_wrapper_open', 10, 2 );
/**
* Display Posts, pan wrapper close
* @see https://displayposts.com/2019/01/23/display-inline-link-with-most-recent-post/
*/
function be_dps_span_wrapper_close( $wrapper, $atts ) {
if( !empty( $atts['wrapper'] ) && 'span' == $atts['wrapper'] )
$wrapper = '</span>';
return $wrapper;
}
add_filter( 'display_posts_shortcode_wrapper_close', 'be_dps_span_wrapper_close', 10, 2 );
/**
* Display Posts, span in output
* @see https://displayposts.com/2019/01/23/display-inline-link-with-most-recent-post/
*/
function be_dps_span_output( $output, $atts ) {
if( !empty( $atts['wrapper'] ) && 'span' == $atts['wrapper'] ) {
$output = str_replace( array( '<div', '<li' ), '<span', $output );
$output = str_replace( array( '</div>', '</li>' ), '</span>', $output );
}
return $output;
}
add_filter( 'display_posts_shortcode_output', 'be_dps_span_output', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment