• I am trying to find a solution to this problem. I checked some plugins, i found one that is special, because is simple, and seams to function for showing one single rondom post. That is great!
    So, i have this function :

    function single_random_post() {
    
    		    global $wpdb;
    		    $query = "SELECT id, post_title, post_name FROM $wpdb->posts WHERE ((post_status='publish') AND (post_type = 'post') AND ($wpdb->posts.post_password = '')) ORDER BY RAND() LIMIT 1";
    		    $randompost = $wpdb->get_results($query);
    		    $post = $randompost[0];
    		    $post_title = htmlspecialchars(stripslashes($post->post_title));
    		    $showpost .= "<a href=\"" . get_permalink($post->id) . "\" title=\"". $post_title ."\">" . $post_title ."</a>\n";
    		    echo $showpost;	
    
    }

    What i try to do is to resolve my issue. I wanna show some text not just the post title.
    Can help me someone with that?

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to display random post with some text’ is closed to new replies.