Not pulling thumbnails from custom post type
-
The plugin is not finding the youtube embed in my custom post type.
I have selected it within the settings but still won’t grab!
Please help me as this site is pure video based and I don’t have time to create thumbnails for hundreds of videos!
-
Can you try embedding it the same way but with the standard post type? My first suspicion is that something else is the problem. If it doesn’t work there either, let me know how you’re embedding the videos (the embed code or the plugin you’re using).
It works on a standard post type.
function custom_posttype_menu_wp_admin1() { //===============Custom SECTION START================ register_post_type( 'videos', array( 'label' => __('Videos'), 'labels' => array( 'name' => __('Video'), 'singular_name' => __('Video'), 'add_new' => __('Add Video'), 'add_new_item' => __('Add New Video'), 'edit' => __('Edit'), 'edit_item' => __('Edit Video'), 'new_item' => __('New Video'), 'view_item' => __('View Video'), 'search_items' => __('Search Videos'), 'not_found' => __('No Videos found'), 'not_found_in_trash' => __('No Videos found in trash') ), 'public' => true, 'can_export' => true, 'show_ui' => true, // UI in admin panel '_builtin' => false, // It's a custom post type, not built in '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'menu_icon' => get_bloginfo('template_url').'/images/favicon.ico', 'hierarchical' => false, 'rewrite' => array("slug" => "videos"), // Permalinks 'query_var' => "videos", // This goes to the WP_Query schema 'supports' => array( 'title', 'author', 'excerpt', 'thumbnail', 'comments', 'editor', 'trackbacks', 'custom-fields', 'revisions') , 'show_in_nav_menus' => true , 'taxonomies' => array('videoscategory','videostags') ) ); // Register custom taxonomy register_taxonomy( "videoscategory", array( "videos" ), array ( "hierarchical" => true, "label" => "Category", 'labels' => array( 'name' => __('Category'), 'singular_name' => __('Category'), 'search_items' => __('Search Category'), 'popular_items' => __('Popular Category'), 'all_items' => __('All Category'), 'parent_item' => __('Parent Category'), 'parent_item_colon' => __('Parent Category:'), 'edit_item' => __('Edit Category'), 'update_item' => __('Update Category'), 'add_new_item' => __('Add New Category'), 'new_item_name' => __('New Make Category') ), 'public' => true, 'show_ui' => true, "rewrite" => true ) ); register_taxonomy( "videostags", array( "videos" ), array( "hierarchical" => false, "label" => "Tags", 'labels' => array( 'name' => __('Tags'), 'singular_name' => __('Tags'), 'search_items' => __('Video Tags'), 'popular_items' => __('Popular Video Tags'), 'all_items' => __('All Video Tags'), 'parent_item' => __('Parent Video Tags'), 'parent_item_colon' => __('Parent Video Tags:'), 'edit_item' => __('Edit Video Tags'), 'update_item' => __('Update Video Tags'), 'add_new_item' => __('Add New Video Tags'), 'new_item_name' => __('New Video Tags Name') ), 'public' => true, 'show_ui' => true, "rewrite" => true ) ); } //===============Custom SECTION END================ /////The filter code to get the custom post type in the RSS feed function myfeed_request($qv) { if (isset($qv['feed'])) $qv['post_type'] = get_post_types(); return $qv; } add_filter('request', 'myfeed_request'); ?>
$pt_metaboxes = array( "video" => array ( "name" => "video", "default" => "", "label" => "Custom Video code", "type" => "textarea", "desc" => "Enter Embedded code for video. Example : You can get the code from youtube, vimeo, etc websites" ), "time" => array ( "name" => "time", "default" => "", "label" => "Video Time", "type" => "text", "desc" => "Enter video playback time (ex.2:02,2:42)" ), "twitter" => array ( "name" => "twitter", "default" => "", "label" => "Video Author Twitter ID", "type" => "text", "desc" => "Twitter ID (ex.https://twitter.com/templatic)" ), "facebook" => array ( "name" => "facebook", "default" => "", "label" => "Video Author Facebook ID", "type" => "text", "desc" => "Facebook ID (ex.https://facebook.com/templatic)" ), ); // Excerpt length // Custom fields for WP write panel // This code is protected under Creative Commons License: https://creativecommons.org/licenses/by-nc-nd/3.0/ function ptthemes_meta_box_content() { global $post, $pt_metaboxes; $output = ''; $output .= '<div class="pt_metaboxes_table">'."\n"; foreach ($pt_metaboxes as $pt_id => $pt_metabox) { if($pt_metabox['type'] == 'text' OR $pt_metabox['type'] == 'select' OR $pt_metabox['type'] == 'checkbox' OR $pt_metabox['type'] == 'textarea') $pt_metaboxvalue = get_post_meta($post->ID,$pt_metabox["name"],true); if ($pt_metaboxvalue == "" || !isset($pt_metaboxvalue)) { $pt_metaboxvalue = $pt_metabox['default']; } if($pt_metabox['type'] == 'text'){ $output .= "\t".'<div>'; $output .= "\t\t".'<br/><p><strong><label for="'.$pt_id.'">'.$pt_metabox['label'].'</label></strong></p>'."\n"; $output .= "\t\t".'<p><input size="100" class="pt_input_text" type="'.$pt_metabox['type'].'" value="'.$pt_metaboxvalue.'" name="ptthemes_'.$pt_metabox["name"].'" id="'.$pt_id.'"/></p>'."\n"; $output .= "\t\t".'<p><span style="font-size:11px">'.$pt_metabox['desc'].'</span></p>'."\n"; $output .= "\t".'</div>'."\n"; } elseif ($pt_metabox['type'] == 'textarea'){ $output .= "\t".'<div>'; $output .= "\t\t".'<br/><p><strong><label for="'.$pt_id.'">'.$pt_metabox['label'].'</label></strong></p>'."\n"; $output .= "\t\t".'<p><textarea rows="5" cols="98" class="pt_input_textarea" name="ptthemes_'.$pt_metabox["name"].'" id="'.$pt_id.'">' . $pt_metaboxvalue . '</textarea></p>'."\n"; $output .= "\t\t".'<p><span style="font-size:11px">'.$pt_metabox['desc'].'</span></p>'."\n"; $output .= "\t".'</div>'."\n"; } elseif ($pt_metabox['type'] == 'select'){ $output .= "\t".'<div>'; $output .= "\t\t".'<br/><p><strong><label for="'.$pt_id.'">'.$pt_metabox['label'].'</label></strong></p>'."\n"; $output .= "\t\t".'<p><select class="pt_input_select" id="'.$pt_id.'" name="ptthemes_'. $pt_metabox["name"] .'"></p>'."\n"; $output .= '<option>Select a Upload</option>'; $array = $pt_metabox['options']; if($array){ foreach ( $array as $id => $option ) { $selected = ''; if($pt_metabox['default'] == $option){$selected = 'selected="selected"';} if($pt_metaboxvalue == $option){$selected = 'selected="selected"';} $output .= '<option value="'. $option .'" '. $selected .'>' . $option .'</option>'; } } $output .= '</select><p><span style="font-size:11px">'.$pt_metabox['desc'].'</span></p>'."\n"; $output .= "\t".'</div>'."\n"; } elseif ($pt_metabox['type'] == 'checkbox'){ if($pt_metaboxvalue == 'on') { $checked = 'checked="checked"';} else {$checked='';} $output .= "\t".'<div>'; $output .= "\t\t".'<br/><p><strong><label for="'.$pt_id.'">'.$pt_metabox['label'].'</label></strong></p>'."\n"; $output .= "\t\t".'<p><input type="checkbox" '.$checked.' class="pt_input_checkbox" id="'.$pt_id.'" name="ptthemes_'. $pt_metabox["name"] .'" /></p>'."\n"; $output .= "\t\t".'<p><span style="font-size:11px">'.$pt_metabox['desc'].'</span></p>'."\n"; $output .= "\t".'</div>'."\n"; } } $output .= '</div>'."\n\n"; echo $output; } function ptthemes_metabox_insert() { global $pt_metaboxes; global $globals; $pID = $_POST['post_ID']; $counter = 0; foreach ($pt_metaboxes as $pt_metabox) { // On Save.. this gets looped in the header response and saves the values submitted if($pt_metabox['type'] == 'text' OR $pt_metabox['type'] == 'select' OR $pt_metabox['type'] == 'checkbox' OR $pt_metabox['type'] == 'textarea') // Normal Type Things... { $var = "ptthemes_".$pt_metabox["name"]; if (isset($_POST[$var])) { if( get_post_meta( $pID, $pt_metabox["name"] ) == "" ) add_post_meta($pID, $pt_metabox["name"], $_POST[$var], true ); elseif($_POST[$var] != get_post_meta($pID, $pt_metabox["name"], true)) update_post_meta($pID, $pt_metabox["name"], $_POST[$var]); elseif($_POST[$var] == "") delete_post_meta($pID, $pt_metabox["name"], get_post_meta($pID, $pt_metabox["name"], true)); } } } } function ptthemes_header_inserts(){ echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/library/functions/admin_style.css" media="screen" />'; } function ptthemes_meta_box() { if ( function_exists('add_meta_box') ) { add_meta_box('ptthemes-settings',$GLOBALS['themename'].' Custom Settings','ptthemes_meta_box_content','videos','normal','high'); } } add_action('admin_menu', 'ptthemes_meta_box'); add_action('admin_head', 'ptthemes_header_inserts'); add_action('save_post', 'ptthemes_metabox_insert'); function relativeDate($posted_date) { $tz = 0; // change this if your web server and weblog are in different timezones // see project page for instructions on how to do this $month = substr($posted_date,4,2); if ($month == "02") { // february // check for leap year $leapYear = isLeapYear(substr($posted_date,0,4)); if ($leapYear) $month_in_seconds = 2505600; // leap year else $month_in_seconds = 2419200; } else { // not february // check to see if the month has 30/31 days in it if ($month == "04" or $month == "06" or $month == "09" or $month == "11") $month_in_seconds = 2592000; // 30 day month else $month_in_seconds = 2678400; // 31 day month; } /* some parts of this implementation borrowed from: https://maniacalrage.net/archives/2004/02/relativedatesusing/ */ $in_seconds = strtotime(substr($posted_date,0,8).' '. substr($posted_date,8,2).':'. substr($posted_date,10,2).':'. substr($posted_date,12,2)); $diff = time() - ($in_seconds + ($tz*3600)); $months = floor($diff/$month_in_seconds); $diff -= $months*2419200; $weeks = floor($diff/604800); $diff -= $weeks*604800; $days = floor($diff/86400); $diff -= $days*86400; $hours = floor($diff/3600); $diff -= $hours*3600; $minutes = floor($diff/60); $diff -= $minutes*60; $seconds = $diff; if ($months>0) { // over a month old, just show date ("Month, Day Year") echo ''; the_time('F jS, Y'); } else { if ($weeks>0) { // weeks and days $relative_date .= ($relative_date?', ':'').$weeks.' '.get_option('ptthemes_relative_week').''.($weeks>1?''.get_option('ptthemes_relative_s').'':''); $relative_date .= $days>0?($relative_date?', ':'').$days.' '.get_option('ptthemes_relative_day').''.($days>1?''.get_option('ptthemes_relative_s').'':''):''; } elseif ($days>0) { // days and hours $relative_date .= ($relative_date?', ':'').$days.' '.get_option('ptthemes_relative_day').''.($days>1?''.get_option('ptthemes_relative_s').'':''); $relative_date .= $hours>0?($relative_date?', ':'').$hours.' '.get_option('ptthemes_relative_hour').''.($hours>1?''.get_option('ptthemes_relative_s').'':''):''; } elseif ($hours>0) { // hours and minutes $relative_date .= ($relative_date?', ':'').$hours.' '.get_option('ptthemes_relative_hour').''.($hours>1?''.get_option('ptthemes_relative_s').'':''); $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' '.get_option('ptthemes_relative_minute').''.($minutes>1?''.get_option('ptthemes_relative_s').'':''):''; } elseif ($minutes>0) { // minutes only $relative_date .= ($relative_date?', ':'').$minutes.' '.get_option('ptthemes_relative_minute').''.($minutes>1?''.get_option('ptthemes_relative_s').'':''); } else { // seconds only $relative_date .= ($relative_date?', ':'').$seconds.' '.get_option('ptthemes_relative_minute').''.($seconds>1?''.get_option('ptthemes_relative_s').'':''); } // show relative date and add proper verbiage echo ''.get_option('ptthemes_relative_posted').' '.$relative_date.' '.get_option('ptthemes_relative_ago').''; } } function isLeapYear($year) { return $year % 4 == 0 && ($year % 400 == 0 || $year % 100 != 0); } if(!function_exists('how_long_ago')){ function how_long_ago($timestamp){ $difference = time() - $timestamp; if($difference >= 60*60*24*365){ // if more than a year ago $int = intval($difference / (60*60*24*365)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_year').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } elseif($difference >= 60*60*24*7*5){ // if more than five weeks ago $int = intval($difference / (60*60*24*30)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_month').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } elseif($difference >= 60*60*24*7){ // if more than a week ago $int = intval($difference / (60*60*24*7)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_week').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } elseif($difference >= 60*60*24){ // if more than a day ago $int = intval($difference / (60*60*24)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_day').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } elseif($difference >= 60*60){ // if more than an hour ago $int = intval($difference / (60*60)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_hour').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } elseif($difference >= 60){ // if more than a minute ago $int = intval($difference / (60)); $s = ($int > 1) ? ''.get_option('ptthemes_relative_s').'' : ''; $r = $int . ' '.get_option('ptthemes_relative_minute').'' . $s . ' '.get_option('ptthemes_relative_ago').''; } else { // if less than a minute ago $r = ''.get_option('ptthemes_relative_moments').' '.get_option('ptthemes_relative_ago').''; } return $r; } } /* popular posts*/ $mostwanted_ver = "0.1.9v"; $total_hits = -1; //$futureSpamOption = ""; $futureSpamOption = "and spam=0"; $cache_until = 0; $cached_result = ""; // what's the table name? $tablestattraq = $table_prefix . 'stattraq'; function rjb_mostwanted($top_n=5, $curtail=0, $showviews=false, $show_views_in_tt=true, $duration = null, $pre="<li>", $post="</li>", $method="ip", $as_percentage = false) { MostWanted::mostwanted($top_n, $curtail, $showviews, $show_views_in_tt, $duration, $pre, $post, $method, $as_percentage); } function mostwanted_conf() { global $tablestattraq; ?> <div class="wrap"> <h2>MostWanted Configuration</h2> <?php if ( isset($_POST['submit']) ) { MostWanted::fixstats($_POST['sleep']); } else { ?> <p>MostWanted uses the database tables from StatTraq to provide a list of the most popular articles.</p> <p>There is a small quirk in StatTraq that results in all page views showing up as "Multiple Posts" in cases where permalinks are used. These stats are not lost, they're just incorrectly recorded, and can be fixed.</p> <p>Currently there are <?php global $wpdb; $q = "SELECT count(*) FROM $tablestattraq WHERE article_id = '0' AND url LIKE '/index.php?name=%'"; $potential = $wpdb->get_var( $q ); _e( $potential ); ?> rows in your database that could be repaired.</p> <p>Between each update, the fix mechanism can pause in order to give the database a rest. This is handy if you're running a live service and don't want the update to be noticed - a value of "0" can safely be used if you are the sole user of the DB and you just want to get the fix done.</p> <form action="" method="post" id="akismet-conf" style="margin: auto; width: 25em; "> <p>Pause time (in seconds)<input type="text" name="sleep" value="1" /></p> <p class="submit"><input type="submit" name="submit" value="Fix stats »" /></p> </form><?php } ?> </div> <?php } class MostWanted { function config_page() { global $wpdb; if ( function_exists('add_submenu_page') ) add_submenu_page('plugins.php', 'MostWanted Configuration', 'MostWanted Config', 1, basename(__FILE__), 'mostwanted_conf'); } function mostwanted($top_n=5, $curtail=0, $showviews=false, $show_views_in_tt=true, $duration="", $pre="<li>", $post="</li>", $method="ip", $as_percentage = false, $timeout=1800){ global $wpdb, $tablestattraq, $tableposts, $user_level, $mostwanted_ver, $total_hits, $cache_until, $cached_result; $time_now = time(); if ($time_now > $cache_until) { // the cache_until time has been passed so the cache is invalid. // the content must therefore be regenerated. $cache_until = $time_now+$timeout; _e("<!-- MostWanted Generated ".$time_now." Expires ".$cache_until." -->"); get_currentuserinfo(); $dateOption = ""; $durationExplained = ""; if ($duration != "") { $dateOption .= "AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < st.access_time"; $durationExplained = " in the last ".$duration." days"; } if ($method == "ip") { $method="ip_address"; } else { $method="session_id"; } $distinct = ($as_percentage?" of":"")." distinct viewers"; $q = "SELECT p.post_title, st.article_id, COUNT( DISTINCT (st.$method) ) as cnt FROM $tablestattraq st, $tableposts p where p.ID=st.article_id AND p.post_status='publish' ".$futureSpamOption." AND st.user_agent_type='0' ".$dateOption." GROUP BY st.article_id ORDER BY cnt DESC LIMIT 0,$top_n"; $output = $wpdb->get_results( $q ); $cached_result=""; _e("<!-- "); _e($q); _e(" -->"); if (isset($output)) { foreach ($output as $line) { if ($showviews) { $views = " ".MostWanted::getHits($as_percentage, $line->cnt, $dateOption).""; } if ($show_views_in_tt) { $ttviews = " (".MostWanted::getHits($as_percentage, $line->cnt, $dateOption).$distinct.$durationExplained.")".$append; } $short = MostWanted::curtail($line->post_title, $curtail) ; $t= str_replace("'","'", $line->post_title); $cached_result .= $pre . "<a title='". $t . $ttviews . "' href='" . get_permalink($line->article_id) . "'>" . ($short) . "</a>".$post; } } else { $cached_result .= $pre . "No results available.".$post; } } else { _e("<!-- MostWanted Cache Hit -->"); // the cache is still valid // there no need to do anything } echo $cached_result; // reset the hits value so it is checked once when // the next page is loaded. $total_hits = -1; return; } function getHits($as_percentage, $count, $dateOption) { global $total_hits, $wpdb; // start percentage lookup if ($as_percentage) { // get the total number of hits if it's not known already if ($total_hits == -1) { $q = "SELECT COUNT( * ) as cnt FROM $tablestattraq st where st.user_agent_type='0'" . $futureSpamOption." ".$dateOption; $total_hits = $wpdb->get_var( $q ); } return "" . round((($count / $total_hits) * 100), 1) . "%"; } else { return $count; } // end percentage lookup } // trims a message down so that it is shorter than the length // specified in the $trim_chars argument. function curtail($trim_this, $trim_chars=0) { if ($trim_chars > 0 && strlen($trim_this) > $trim_chars) { return substr($trim_this,0,($trim_chars-3)) . “…”; } return $trim_this; } // adds a signature to the end of your page describing the // version of MostWanted, which is rather handy when debugging // from afar. function signature() { global $mostwanted_ver; echo "\n\n<link href='https://boakes.org/most-wanted?v=".$mostwanted_ver."' />\n"; } // This utility method is not used by the main plugin. It is as a // repair tool for stattraq data which may be incorrectly recorded // without an article_id, which means that the data can't show up // in the MostWanted output. // // If you've not hacked your stattraq plugin to fix this, then // a call to this method will repair all entries in your database. function fixstats($sleep = 1){ global $wpdb, $tablestattraq, $tableposts; get_currentuserinfo(); // calculate duration $output = $wpdb->get_results( "SELECT COUNT( DISTINCT (ID) ) as cnt FROM $wpdb->posts;" ); foreach ($output as $line) { $duration = ($sleep * $line->cnt) /60; } _e("<p>MostWanted is now updating your stattraq database as a LOW_PRIORITY task. This will probably take around " . $duration . " minutes. Your previous statistics are being ever-so-slightly-repaired. Every record of a post that was accessed using a permalink is having it's post id added to it.</p><ol>"); _e("<p>This page shows the progress of that process. If you wander off to another page, the process will continue in the background, but you won't know precicely when it's complete.</p>"); $output = $wpdb->get_results( "SELECT id, post_name FROM $wpdb->posts where post_status = 'publish' ORDER BY id DESC;" ); foreach ($output as $line) { $q = "SELECT count(*) from $tablestattraq WHERE (article_id = '0' and url like '%name=" . $line->post_name . "%');"; $changes = $wpdb->get_var( $q ); if ($changes > 0) { $q = "UPDATE low_priority $tablestattraq SET article_id = '" . $line->id . "' WHERE (article_id = '0' and url like '%name=" . $line->post_name . "%');"; _e("<li class='active'><span class='name'>Converting " . $line->post_name); $o2 = $wpdb->get_results( $q ); _e(" - $changes rows altered"); if ($sleep > 0) { _e(" - sleeping for " . $sleep . " seconds"); } _e("</span></li>"); flush(); sleep($sleep); } else { _e("<li>Skipping " . $line->post_name . " because no rows require update</li>"); } ob_end_flush(); } _e("</ol>"); _e("<h1>Finished!</h1>"); return; } } add_action('wp_head', array('MostWanted', 'signature')); add_action('admin_menu', array('MostWanted', 'config_page')); // NOTE the ">" symbol in the following line must // be the last character in the file - do not add // any spaces, tabs or newlines after it, or you // will get "header already sent" errors. /* Plugin Name: WP-PageNavi Plugin URI: https://www.lesterchan.net/portfolio/programming.php */ function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { global $request, $posts_per_page, $wpdb, $paged; if(empty($prelabel)) { $prelabel = '<strong>«</strong>'; } if(empty($nxtlabel)) { $nxtlabel = '<strong>»</strong>'; } $half_pages_to_show = round($pages_to_show/2); if (!is_single()) { if(is_tag()) { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } elseif (!is_category()) { preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); $max_page = ceil($numposts /$posts_per_page); if(empty($paged)) { $paged = 1; } if($max_page > 1 || $always_show) { echo "$before <div class='Navi'>"; if ($paged >= ($pages_to_show-1)) { echo '<a href="'.get_pagenum_link().'">« '.get_option('ptthemes_pagination_first_name').'</a>'; } previous_posts_link($prelabel); for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) { echo "<strong class='on'>$i</strong>"; } else { echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> '; } } } next_posts_link($nxtlabel, $max_page); if (($paged+$half_pages_to_show) < ($max_page)) { echo '<a href="'.get_pagenum_link($max_page).'">'.get_option('ptthemes_pagination_last_name').' »</a>'; } echo "</div> $after"; } } } // Use Noindex for sections specified in theme admin function ptthemes_noindex_head() { if ((is_category() && get_option('ptthemes_noindex_category')) || (is_tag() && get_option('ptthemes_noindex_tag')) || (is_day() && get_option('ptthemes_noindex_daily')) || (is_month() && get_option('ptthemes_noindex_monthly')) || (is_year() && get_option('ptthemes_noindex_yearly')) || (is_author() && get_option('ptthemes_noindex_author')) || (is_search() && get_option('ptthemes_noindex_search'))) { $meta_string .= '<meta name="robots" content="noindex,follow" />'; } echo $meta_string; } add_action('wp_head', 'ptthemes_noindex_head'); ///////////NEW FUNCTIONS START////// function bdw_get_images($iPostID,$img_size='thumb') { $arrImages =& get_children('order=ASC&orderby=menu_order ID&post_type=attachment&post_mime_type=image&post_parent=' . $iPostID ); //$images =& get_children( 'post_type=attachment&post_mime_type=image' ); //$videos =& get_children( 'post_type=attachment&post_mime_type=video/mp4' ); $return_arr = array(); if($arrImages) { foreach($arrImages as $key=>$val) { $id = $val->ID; if($img_size == 'large') { //$return_arr[] = '<img src="'.wp_get_attachment_url($id).'" alt="">'; // THE FULL SIZE IMAGE INSTEAD $img_arr = wp_get_attachment_image_src($id,'full'); // THE FULL SIZE IMAGE INSTEAD $return_arr[] = $img_arr[0]; } elseif($img_size == 'medium') { //$return_arr[] = '<img src="'.wp_get_attachment_url($id, $size='medium').'" alt="">'; //THE medium SIZE IMAGE INSTEAD $img_arr = wp_get_attachment_image_src($id, 'medium'); //THE medium SIZE IMAGE INSTEAD $return_arr[] = $img_arr[0]; } elseif($img_size == 'thumb') { //$return_arr[] = '<img src="'.wp_get_attachment_thumb_url($id).'" alt="">'; // Get the thumbnail url for the attachment $img_arr = wp_get_attachment_image_src($id, 'thumbnail'); // Get the thumbnail url for the attachment $return_arr[] = $img_arr[0]; } } return $return_arr; } } function excerpt($limit=10) { $excerpt = explode(' ', get_the_excerpt(),$limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt); return $excerpt; } function content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/\[.+\]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } function get_related_posts($postdata) { $postCatArr = wp_get_post_categories($postdata->ID); $post_array = array(); for($c=0;$c<count($postCatArr);$c++) { $category_posts=get_posts('category='.$postCatArr[$c]); foreach($category_posts as $post) { if($post->ID != $postdata->ID) { $post_array[$post->ID] = $post; } } } if($post_array) { ?> <div class="realated_post clearfix"> <h3><span>Related Posts</span></h3><ul class="categories_list clearfix"> <?php $relatedprd_count = 0; foreach($post_array as $postval) { $product_id = $postval->ID; $post_title = $postval->post_title; $productlink = get_permalink($product_id); $post_date = $postval->post_date; $comment_count = $postval->comment_count; if($postval->post_status == 'publish') { $post_images = bdw_get_images($postval->ID,'large'); if($post_images[0]!='') { $relatedprd_count++; ?> <li class="clearfix"> <?php if(get_the_post_thumbnail( $post->ID, array())){?> <a class="video_thumb" href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="<?php the_title(); ?>"> <?php echo get_the_post_thumbnail( $post->ID, array(123,100),array('class' => "",));?> </a> <?php }else if($post_images[0]){ global $thumb_url; $thumb_url1 = $thumb_url.get_image_cutting_edge($args); ?> <a class="video_thumb" href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="<?php the_title(); ?>"> <img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo $post_images[0];?>&w=123&h=100&zc=1&q=80<?php echo $thumb_url1;?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /> </a> <?php } else { ?> <a href="<?php echo get_permalink($post->ID) ?>"> <span class="img_not_available"> <?php _e('Image Not Available ');?> </span> </a> <?php }?> <p class="title"> <a href="<?php echo $productlink; ?>"><?php echo $post_title; ?></a></p> <p class="author"> by <?php the_author_posts_link(); ?></p> </li> <?php if($relatedprd_count==4){ break;} } } } ?> </ul> </div> <?php } } function get_blog_sub_cats_str($type='array') { $catid_arr = get_option('ptthemes_blogcategory'); $blogcatids = ''; $subcatids_arr = array(); for($i=0;$i<count($catid_arr);$i++) { if($catid_arr[$i]) { $subcatids_arr = array_merge($subcatids_arr,array($catid_arr[$i]),get_term_children( $catid_arr[$i],'category')); } } if($subcatids_arr && $type=='string') { $blogcatids = implode(',',$subcatids_arr); return $blogcatids; }else { return $subcatids_arr; } } ?>
There is my code to embed youtube videos.
So you’re putting the embed code into a custom meta box? Currently only the post body itself it searched, but you should be able to use it with your custom meta box by replacing these lines:
// Gets the post's content $post_array = get_post($post_id); $markup = $post_array->post_content; $markup = apply_filters('the_content',$markup); $new_thumbnail = null;
with:
// Gets the post's content $video_key = 'video'; $markup = get_post_meta($post_id, $video_key, true); $new_thumbnail = null;
You may have to tweak the value of $video_key = ‘video’; but I think this should work. Let me know your results.
Worked perfectly thanks!!!
I’m in a similar situation were the video thumbnails are not pulling from any of my custom post types. Any help you can offer would be greatly appreciated.
Here’s my functions.php file currently for my custom post type.
//Video Portfolio Post Type register_post_type('video-portfolio', array( 'label' => 'Video Portfolio','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => ''),'query_var' => true,'has_archive' => true,'supports' => array('title','editor','thumbnail',),'labels' => array ( 'name' => 'Video Portfolio', 'singular_name' => 'Project', 'menu_name' => 'Video Portfolio', 'add_new' => 'Add Project', 'add_new_item' => 'Add New Project', 'edit' => 'Edit', 'edit_item' => 'Edit Project', 'new_item' => 'New Project', 'view' => 'View Project', 'view_item' => 'View Project', 'search_items' => 'Search Video Portfolio', 'not_found' => 'No Video Portfolio Found', 'not_found_in_trash' => 'No Video Portfolio Found in Trash', 'parent' => 'Parent Project', ),) ); register_taxonomy('project-type',array ( 0 => 'video-portfolio', ),array( 'hierarchical' => true, 'label' => 'Project Type','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'project-type') );
And…. here’s how I am displaying the custom post type yet the video thumbnail is not working. Thanks…
<?php $looptwo = new WP_Query( array( 'post_type' => 'video-portfolio', 'posts_per_page' => 4 ) ); ?> <?php while ( $looptwo->have_posts() ) : $looptwo->the_post(); ?> <article> <div class="image"> <a href=""> <?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) :?> <img src="<?php video_thumbnail(); ?>" alt=""/> <? elseif(has_post_thumbnail()) : ?> <?php the_post_thumbnail(); ?> <?php else :?> <?php endif;?> </a> </div><!-- end image --> <div class="description"> <h3><a href=""><?php the_title(); ?></a></h3> </div><!-- end description --> <div class="clearfix"></div> </article> <?php endwhile; ?> <?php wp_reset_query(); ?>
First thing I’d recommend is simplifying your code a bit. If you have the plugin set to save thumbnails to your media library and set as featured image, you can change all of this:
<?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) :?> <img src="<?php video_thumbnail(); ?>" alt=""/> <? elseif(has_post_thumbnail()) : ?> <?php the_post_thumbnail(); ?> <?php else :?> <?php endif;?>
to just this:
<?php if(has_post_thumbnail()) : ?> <?php the_post_thumbnail(); ?> <?php endif;?>
It’s possible that where you had
<? elseif(...
could be causing problems depending on your server’s php configuration.Also be sure to check that your settings have the correct custom post type selected and the custom field blank.
I ended up getting it working with my initial code, not sure what was going wrong at first. And I ended up going that route because I didn’t want to save the thumbnails to my site because I wanted those to remain dynamic in hope that they would change if I change them on vimeo.
@nbqmedia; … i think you’re using Templatic Video theme. i’m also and i have same issue. but i can’t solve. can you help me, please?
@bsetter I’m not sure Vimeo’s thumbnail URLs will stay the same if the image is changed, so you might actually end up with broken images. I haven’t actually tested it, so let me know if that ends up being the case or not.
@ibalaban since his issue the plugin has been updated, so all you should need to do is choose the right post type in the Video Thumbnails settings page and enter the name of the custom field it stores your video in. This could be something like ‘video’ or ’embed_code’ but varies from theme to theme.
- The topic ‘Not pulling thumbnails from custom post type’ is closed to new replies.