Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active January 4, 2019 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/1270278 to your computer and use it in GitHub Desktop.
Save billerickson/1270278 to your computer and use it in GitHub Desktop.
Customize outer markup of Display Posts Shortcode
<?php
/**
* Customize opening outer markup of Display Posts Shortcode
* @see https://displayposts.com/2019/01/04/use-section-element-for-wrapper/
*
* @param $output string, the original opening markup
* @return $output string, the modified opening markup
*/
function be_display_posts_open( $output, $atts, $query ) {
$output = '<section class="display-posts-listing">';
return $output;
}
add_filter( 'display_posts_shortcode_wrapper_open', 'be_display_posts_open', 10, 3 );
/**
* Customize closing outer markup of Display Posts Shortcode
* @see https://displayposts.com/2019/01/04/use-section-element-for-wrapper/
*
* @param $output string, the original closing markup
* @return $output string, the modified closing markup
*/
function be_display_posts_close( $output, $atts, $query ) {
$output = '</section>';
return $output;
}
add_filter( 'display_posts_shortcode_wrapper_close', 'be_display_posts_close', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment