• Resolved keyaspects

    (@keyaspects)


    Hi,

    I’m having trouble getting a random video via a custom field to display in a drop down menu.
    I have assigned the following custom field to posts within the ‘videos’ category. ‘recent_video’

    The custom field contains the url address of the video and nothing else.

    The video displays fine if you are on the viewing a post within the videos category or a list of posts from the videos category.

    But doesn’t display any other time

    here’s the code `<div class=”col_2″>

    <?php
    $args = array(
    ‘numberposts’ => 1,
    ‘category’ => ‘Videos’,
    ‘post_type’ => ‘recent_video’,
    ‘orderby’ => ‘rand’
    );
    $postslist = get_posts( $args );

    echo ‘<iframe title=”Video” width=”270″ height=”167″ src=”‘ . get_post_meta($post->ID, ‘recent_video’ , true) . ‘” frameborder=”0″ allowfullscreen></iframe>’; ?>

    <a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”<?php the_title(); ?>”>Read the post this video came from</a>

    <?php wp_reset_query(); ?>

    </div>`

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Random Custom field video’ is closed to new replies.