WordPress.org

Ready to get started?Download WordPress

Forums

Random post (1 post)

  1. TataVostru
    Member
    Posted 1 year ago #

    how to get random post by a post_type
    i have this

    <?php
    $recentPosts = new WP_Query();
    $recentPosts->query(array('showposts' => 10, 'post_type' =>array('trailers')));
    ?>
    
    <div class="sidebar-box-tr">
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <div class="sidebar-tr-titlu"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    <div class="sidebar-tr">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Trailer film %s', 'kubrick'), the_title_attribute('echo=0')); ?>"></a>
    <span class="viz-tr"><b>Anul:</b> <?php $key="an_trailer"; echo get_post_meta($post->ID, $key, true); ?></span>
    
    <img src="http://img.youtube.com/vi/<?php $key="trailer"; echo get_post_meta($post->ID, $key, true); ?>/<?php $key="img_trailer"; echo get_post_meta($post->ID, $key, true); ?>">
    </div>
    <?php endwhile; ?>
    </div>

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic