WordPress.org

Forums

[resolved] Retrieve articles (category news) with more button working (3 posts)

  1. anve
    Member
    Posted 3 years ago #

    I want to display the blog entries of my custom theme. The entries of the category news is displayed, but the more button placed into an article doesn't do anything. It is always the full text displayed. This is my code in page.php:

    global $more;
    $more = 0;
    global $post;
    
    $args = array('post_type' => 'post', 'category' => 8, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish');
    $news = get_posts($args);
    if (have_posts()) :
    	foreach ($news as $post) :
    		setup_postdata($post);
    		echo '<div class="article">';
    		$date = get_the_date(get_option('date_format'), $post->ID);
    		echo '<p class="article-date">' . $date . '</p>';
    		echo '<p class="article-heading">' . $post->post_title . '</strong></p>';
    		echo '<p class="article-content">' . the_content('',TRUE) . '</p>';
    		echo '<p class="article-more"><a href="' . get_permalink($post->ID) . '" title="Details">Details</a>';
    		echo '</div>';
    	endforeach;
    endif;

    What I'm missing?

    Thanks in advance!

  2. vtxyzzy
    Member
    Posted 3 years ago #

    Try moving the $more = 0; to after setup_postdata($post);.

  3. anve
    Member
    Posted 3 years ago #

    Thanks it worked!

Topic Closed

This topic has been closed to new replies.

About this Topic