-
-
Save billerickson/c92b742450b20a53c09d8b8277e211e2 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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