Created
April 30, 2015 13:04
-
-
Save thadallender/7e939afc30b16aba5f83 to your computer and use it in GitHub Desktop.
Filter the
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove the default Sell Media action. | |
* We'll replace it with our own custom action hook below. | |
*/ | |
remove_action( 'sell_media_before_content', 'sell_media_append_media' ); | |
/** | |
* Add our new action hook to alter the media (featured image, etc) before the_content in Sell Media | |
* | |
* @param $post_id | |
* | |
* @param $content The the_content field of the item object | |
* @return string the content with any additional data attached | |
*/ | |
function my_sell_media_append_media( $post_id ) { | |
$sell_media_taxonomies = get_object_taxonomies( 'sell_media_item' ); | |
if ( is_post_type_archive( 'sell_media_item' ) || is_tax( $sell_media_taxonomies ) || is_search() ) { | |
echo 'This message will appear on archives and searches for Sell Media.'; | |
} elseif ( is_singular( 'sell_media_item' ) ) { | |
sell_media_set_post_views( $post_id ); | |
if ( sell_media_has_multiple_attachments( $post_id ) ) { | |
echo 'This message will appear on gallery entries for Sell Media.'; | |
} else { | |
echo 'This message will appear on single for Sell Media.'; | |
} | |
} | |
} | |
add_action( 'sell_media_before_content', 'my_sell_media_append_media', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment