WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] post "excerpt" not displaying for popular posts (5 posts)

  1. wildbug
    Member
    Posted 4 years ago #

    My theme displays popular posts on the front page. Right now I can only see post titles and thumbnails. I found this in the functions.php, showing the layout that should appear but the excerpt is not showing up. Anyone know what I can do to fix it...I'm guessing it might be an easy fix. Thank you to anyone that can help!!

    # Displays a list of popular posts
    function fs_popular_posts($num, $pre='<li>', $suf='</li>', $excerpt=true) {
    	global $wpdb, $post;
    	$querystr = "SELECT $wpdb->posts.post_title, $wpdb->posts.comment_count, $wpdb->posts.ID, $wpdb->posts.post_content FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ORDER BY $wpdb->posts.comment_count DESC LIMIT $num";
    	$myposts = $wpdb->get_results($querystr, OBJECT);
    	foreach($myposts as $post) {
    		echo $pre;
    		?>
    		<?php if (fs_settings('popular_thumb')=='enabled') : ?>
    		<?php fs_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?>
    		<?php endif; ?>
    		<a href="<?php echo get_permalink($post->ID); ?>"><?php the_title(); ?></a>
    		<p><?php echo fs_clean($post->post_excerpt, 177); ?></p>
    		<?php
    		echo $suf;
    	}
    }
  2. wildbug
    Member
    Posted 4 years ago #

    Seems like I am using the wrong term for excerpts. The original code had "post_content" and I changed it.

  3. wildbug
    Member
    Posted 4 years ago #

    Strange, I can find "post_excerpt" as a term in the support forum but for some reason, it doesn't work here. Post_content does work however. But I need to use the excerpt. Any ideas?

  4. wildbug
    Member
    Posted 4 years ago #

    Yay, I figured it out!! I had to change a term in the query string...

  5. ovib
    Member
    Posted 4 years ago #

    And how did you solved?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags