Skip to content

Instantly share code, notes, and snippets.

@reasonstousegenesis
Last active August 29, 2015 14:20
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 reasonstousegenesis/02275c64cb81450d40b9 to your computer and use it in GitHub Desktop.
Save reasonstousegenesis/02275c64cb81450d40b9 to your computer and use it in GitHub Desktop.
Set a fallback featured image based on category
<?php
// Paste the code BELOW this line into your child theme functions.
/**
* Set a fallback featured image based on category
*
* @author Reasons to Use Genesis
* @link http://reasonstousegenesis.com/default-featured-image/
*/
add_filter( 'genesis_get_image_default_args', 'rtug_fallback_featured_image_category' );
function rtug_fallback_featured_image_category( $defaults ) {
if ( in_category( 'Example Category 1' ) ) // replace with your category title
$defaults[ 'fallback' ] = 200; // replace with your attachment ID
if ( in_category( 'Example Category 2' ) ) // replace with your category title
$defaults[ 'fallback' ] = 400; // replace with your attachment ID
return $defaults;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment