Skip to content

Instantly share code, notes, and snippets.

@bencooling
Created December 17, 2012 04:07
Show Gist options
  • Save bencooling/4315692 to your computer and use it in GitHub Desktop.
Save bencooling/4315692 to your computer and use it in GitHub Desktop.
Wordpress excerpt (teaser) snippets
/* Replace the_content() more text with a template part
------------------------------------------------------------------------------------*/
add_filter( 'the_content_more_link', 'my_the_content_more_link', 10, 2 );
function my_the_content_more_link( $more_link, $more_link_text ) {
return load_template_part('general', 'specific'); // loads general-specific.php, uses custom function load_template_part
}
// Get template partial as variable
function load_template_part($template_name, $part_name=null) {
ob_start();
get_template_part($template_name, $part_name);
$var = ob_get_contents();
ob_end_clean();
return $var;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment