Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress php query randomise

//Create WordPress Query with 'orderby' set to 'rand' (Random)
$the_query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1' ) );
// output the random post
while ( $the_query->have_posts() ) : $the_query->the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Post Data
wp_reset_postdata();
Comment

PREVIOUS NEXT
Code Example
Php :: full month name php 
Php :: query string in laravel 
Php :: php file extension 
Php :: twig or 
Php :: laravel httaccess for apache 
Php :: how to insert multiple selected checkbox values in database in php 
Php :: laravel tree 
Php :: spl_autoload_register 
Php :: Displaying the category name of a custom post type 
Php :: laravel fortify 
Php :: laravel query builder get data as array of array 
Php :: 0 
Php :: update many laravel 
Php :: php 7 starts with 
Php :: if is front end wp 
Php :: add custom page to wordpress 
Php :: Laravel assets url issue 
Php :: how to sent request in php 
Php :: apiresource laravel 
Php :: convert php to python online 
Php :: advanced custom forms php 
Php :: do i need to install php after xampp 
Php :: laravel logout current user 
Php :: codeigniter abort 404 
Php :: Laravel Retrieve All Session Data 
Php :: wp query meta in array 
Php :: format a number with leading zeros in php 
Php :: how to named route resource laravel 
Php :: php is_int 
Php :: General error: 1390 Prepared statement contains too many placeholders 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =