WordPress.org

Ready to get started?Download WordPress

Forums

how to call post limited by category (4 posts)

  1. fzishk
    Member
    Posted 1 year ago #

    hi, i m calling my post by category name : the given code is working well but i need to do that i want to make limit of post, i want to show only on latest post! can any one tell me how should my arrange while loop or by for loop??

    <?php
    
    //The Query
    $query = new WP_Query( 'category_name=Business-News' );
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    	$queried_post = get_post($cat_id);
    	echo $queried_post->post_thumbnail;
    	echo $queried_post->post_content;
    	echo '</li>
    ';
    endwhile;
    echo '</ul>';
    	?>

    [please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

  3. fzishk
    Member
    Posted 1 year ago #

    thnx solved :)

    now another thing which i wish to add in may post ! i m calling title,img and paragraph in my post, but the paragraph showing fully, i want to show just 2 or 3 line with img and then "More" button should be display dynamically so the user can see full post in next page... ?? any idea ?

  4. fzishk
    Member
    Posted 1 year ago #

    //The Query
    $query = new WP_Query( 'category_name=Eham khabren&posts_per_page=1' );
    echo '

      ';
      //The Loop
      while ( $query->have_posts() ) : $query->the_post();
      echo '
    • ';
      $queried_post = get_post($cat_id);
      echo $queried_post->post_thumbnail;
      echo $queried_post->post_content;
      echo '
    • ';
      endwhile;
      echo '
    ';

Topic Closed

This topic has been closed to new replies.

About this Topic