Skip to content

Instantly share code, notes, and snippets.

@brandondove
Last active December 20, 2015 12:49
Show Gist options
  • Save brandondove/6134031 to your computer and use it in GitHub Desktop.
Save brandondove/6134031 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'the_content', 'custom_before_content' );
function custom_before_content ( $content = '' ) {
// Just drop in content in the your_text variable. It can be html or plain
$category = get_the_category();
switch( $category[0]->cat_name ) {
case 'Category 1' :
$your_text = 'Category 1';
default :
$your_text = 'Default';
}
return $your_text.$content;
}
add_filter( 'the_content', 'custom_after_content' );
function custom_after_content ( $content = '' ) {
$category = get_the_category();
switch( $category[0]->cat_name ) {
case 'Category 1' :
$your_text = 'Category 1';
default :
$your_text = 'Default';
}
return $content.$your_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment