Hello i'm trying to display a Post Title by its ID and its thumb content, I have I code but this displays everything, all I want is post title,its category and a short content of that post. I have a code but it displays all of the contents thanks
1 Answer
For Display post title inside the loop you can use following
For Post title <?php the_title(); ?>
For Post Short Content <?php the_excerpt(); ?>
For Post Category <?php twentyten_posted_in(); ?>
Or Display post title out side the loop
use global variable $post <?php global $post; ?>
For Post title <?php $post->post_title; ?>
For Post Short Content <?php $post->post_excerpt; ?>
-
Thanks Sir I have These code all I need now is to echo along the title its excerpt thanks
<?php if (empty($pop_posts) || $pop_posts < 1) $pop_posts = 6; $popularposts = "SELECT ID,post_title FROM {$wpdb->prefix}posts WHERE ID='501' OR ID='2043' OR ID='444' OR ID='670' OR ID='1383' OR ID='1954' AND post_status = 'publish' AND post_type = 'post' ORDER BY comment_count DESC LIMIT 0,".$pop_posts;
Commented Feb 15, 2012 at 7:42 -
$posts = $wpdb->get_results($popularposts); if($posts){ foreach($posts as $post){ $post_title = stripslashes($post->post_title); $guid = get_permalink($post->ID); $popular .= '<li><a href="'.$guid.'" title="'.$post_title.'">'.$post_title.'</a></li>'; } }echo $popular; ?>
Commented Feb 15, 2012 at 7:42 -
@dekzgimutao code like that should be going in your question, not a comment...much less multiple comments.– mor7iferCommented Feb 15, 2012 at 15:52