Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created January 11, 2018 05:10
Show Gist options
  • Select an option

  • Save pbrocks/1b42f2e26099e46e838dcb841ead226f to your computer and use it in GitHub Desktop.

Select an option

Save pbrocks/1b42f2e26099e46e838dcb841ead226f to your computer and use it in GitHub Desktop.
neato-content-filter.php is a sample filter for the_content in WordPress
add_filter( 'the_content', 'neato_content_filter', 20 );
/**
* Add a spinning icon to the beginning of every post page.
*
* @uses is_single()
*/
function neato_content_filter( $content ) {
if ( is_page() ) {
// Add image to the beginning of each page
$content = sprintf(
'<img class="post-icon" src="%s/images/spinner-2x.gif" alt="Post icon" title=""/>%s',
home_url( 'wp-includes' ),
$content
);
}
// Returns the content.
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment