Skip to content

Instantly share code, notes, and snippets.

@billerickson

billerickson/functions.php Secret

Created Jan 23, 2019
Embed
What would you like to do?
<?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