• Hi

    How can this code be altered so that only posts show and not pages.

    <? php cypher_latestposts(); ?>
    
    */
    
    function cypher_latestposts($before='', $after='<br />') {
    
    	global $wpdb;
    	$output = '';
    	$max_posts = 1;	//Maximum posts to be displayed
    
    	$request = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status ='publish' ";
    	$request .= "ORDER BY post_date DESC LIMIT $max_posts";
    	$posts = $wpdb->get_results($request);
    
    	if($posts){
    
    		foreach ($posts as $post){
    			$post_title = stripslashes($post->post_title);
    			$post_link = stripslashes($post->ID);
    			$post_date = stripslashes($post->post_date);
    
    			//$output .= $before . $post_date . $after;
    			$output .= $before . '<a href="?p=' . $post_link . '" rel="Bookmark" title="Permanent Link to ' . $post_title . '">' . $post_title . '</a>';
    			$output .= $after;
    		}
    	}
    	echo $output;
    }
    ?>

    The author’s website is down so I can’t ask him.

    Regards
    Bluepslayer

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show only recent posts and not pages.’ is closed to new replies.