从" post-format-video"获取网址视频

时间:2017-03-24 18:22:22

标签: wordpress url video

我在我的主页上创建了一个动态部分,只有帖子格式的视频。现在我需要从这些视频中获取URL ...

我已经获得了标题,链接和日期:

<div class="container">
<div class="row">
    <div id="layer-videos-section">
        <?php
        $myposts = new WP_Query( array(
            'tax_query' => array(
                array(                
                    'taxonomy' => 'post_format',
                    'field' => 'slug',
                    'terms' => 'post-format-video'
                )
            )
        ) );

        // Open the loop
        if ( $myposts->have_posts() ) : while ( $myposts->have_posts() ) : $myposts->the_post();

            $year = mysql2date('Y', $post->post_date);
            $month = mysql2date('n', $post->post_date);
            $day = mysql2date('j', $post->post_date);    
            ?>

            <p>
                <span class="the_article">
                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                </span>
                &nbsp;&nbsp;&nbsp;
                <span class="the_day">
                    <?php the_time('j F Y'); ?>
                </span>
            </p>  
            <?php 

        // Close the loop
        endwhile; endif;

        // Reset $post data to default query
        wp_reset_postdata();
        ?>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

我明白了! 我安装了插件Featured Video Plus并使用此插件中的本机函数获取了vídeo网址:

get_the_post_video_url( $post_id )
相关问题