Skip to content

Instantly share code, notes, and snippets.

@thadallender
Created April 30, 2015 13:04
Show Gist options
  • Save thadallender/7e939afc30b16aba5f83 to your computer and use it in GitHub Desktop.
Save thadallender/7e939afc30b16aba5f83 to your computer and use it in GitHub Desktop.
Filter the
<?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