Skip to content

Instantly share code, notes, and snippets.

@aliaghdam
Created September 13, 2017 08:50
Show Gist options
  • Save aliaghdam/d35c57afaa4be1eb6bea48643fe1817f to your computer and use it in GitHub Desktop.
Save aliaghdam/d35c57afaa4be1eb6bea48643fe1817f to your computer and use it in GitHub Desktop.
Show Newspaper (by TagDiv) post videos in Publisher (by BetterStudio)
<?php
add_filter( "get_post_metadata", 'bs_replace_td_video_code', 10, 4 );
function bs_replace_td_video_code( $null, $object_id, $meta_key, $single ) {
if ( $meta_key == '_featured_embed_code' ) {
remove_filter( "get_post_metadata", 'bs_replace_td_video_code', 10 );
$td = get_post_meta( $object_id, 'td_post_video', TRUE );
add_filter( "get_post_metadata", 'bs_replace_td_video_code', 10, 4 );
if ( ! empty( $td ) && is_array( $td ) && isset( $td['td_video'] ) ) {
return $td['td_video'];
}
}
return $null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment