jeudi 15 octobre 2015

How to pull through custom post type by custom taxonomy?

I've made a custom post type type called "Videos" and within that post type a custom category called "Crystal" while using this plugin(http://ift.tt/1zfJb86 to generate the YouTube videos thumbnail into the post.

I'm trying to pull through all of the Crystal posts and only display the video thumbnail on the page with a permalink to the post.

Here is my code;

<div class="block" id="home-three">
    <p>YouTube</p>

        <?php
            $args = array(
                'post_type'         => 'videos',
                'post_status'       => 'publish',
                'posts_per_page'    => -1,
                'orderby'           => 'date',
                'order'             => 'DESC',
                'post_parent'       => 0,
                'tax_query'         => 'crystal',
            );

            $count = 1;
        ?>  
        <?php $video_query = new WP_Query( $args ); ?>

            <?php while ( $video_query->have_posts() ) : $video_query->the_post(); ?>

                <div>
                    <a href="<?php the_permalink(); ?>">
                        <?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) { echo "<img src='http://ift.tt/1zfJb86" . $video_thumbnail . "' />"; } ?>
                    </a>
                </div>
            <?php wp_reset_query(); ?>
</div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire