Listado de Vídeos

En el siguiente listado podrás acceder a todos y cada uno de los vídeos publicados por Webipedia HD, los cuales se encuentran organizados por categorías.

[insert_php]
global $wpdb;
global $post;
$categorias = get_categories();
foreach($categorias as $categoria) {
if (empty($categoria->parent)) {
echo ‘

‘.$categoria->name.’

‘;
$child_categories = get_categories(array(‘parent’ => $categoria->term_id));
foreach($child_categories as $child) {
echo ‘

‘.$child->name.’

‘;
$str = “SELECT p.* FROM wp_posts p LEFT JOIN wp_postmeta pm ON (p.ID = pm.post_id) LEFT JOIN wp_term_relationships tr ON (p.ID = tr.object_id) LEFT JOIN wp_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) LEFT JOIN wp_terms t ON (tt.term_id = t.term_id) WHERE p.post_type=’post’ AND p.post_status = ‘publish’ AND tt.taxonomy = ‘category’ AND (pm.meta_key = ‘video’ OR pm.meta_key = ‘video2’) AND pm.meta_value <> ” AND t.term_id = “.$child->term_id;
$result = $wpdb->get_results($str);
echo ‘

    ‘;
    foreach($result as $post) {
    setup_postdata($post);
    $video = get_post_meta(get_the_ID(),’video’,true);
    $idVideo = substr($video, strrpos($video, ‘/’) + 1);
    $coletilla = ”;
    if (in_array($idVideo,$idsVideo)) {
    $video = get_post_meta(get_the_ID(),’video2′,true);
    $idVideo = substr($video, strrpos($video, ‘/’) + 1);
    $coletilla = ‘ (2/2)’;
    }
    else if (!empty(get_post_meta(get_the_ID(),’video2′,true))) {
    $coletilla = ‘ (1/2)’;
    }
    if (strncmp($idVideo, ‘watch?v=’, strlen(‘watch?v=’)) === 0) {
    $idVideo = substr($idVideo, strrpos($idVideo, ‘?v=’) + 3);
    }
    $idsVideo[count($idsVideo)] = $idVideo;
    echo ‘

  • ‘;
    /*
    if (has_post_thumbnail()) {
    the_post_thumbnail(array(64,36));
    echo ‘ ‘;
    }
    */
    echo the_title(”,”,false).$coletilla.’
  • ‘;
    }
    echo ‘

‘;
}
}
}
[/insert_php]