Title: get 1 post only
Last modified: August 18, 2016

---

# get 1 post only

 *  [cam_oai](https://wordpress.org/support/users/cam_oai/)
 * (@cam_oai)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/)
 * hey guys,
    just have some prob, how do i query only 1 post? i tried:
 * <?php $posts = get_posts( “category=5&post=30” ); ?>
    <?php if( $posts ) : ?>
   <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <?php the_content();?
   >
 *  _Last updated: <?php the\_time(‘M j, Y’) ?>_ <?php edit_post_link(‘Edit’); ?
   >
    <?php endforeach; ?> <?php endif; ?>
 * i think this
    <?php $posts = get_posts( “category=5&post=30” ); ?> is wrong. 
   it doesn’t pull 1 post but retreive all posts in cat5. how can i limit it to 
   cat5 but get postid 89 ?
 * tnx

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [spud_8350](https://wordpress.org/support/users/spud_8350/)
 * (@spud_8350)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339034)
 * under options in wp-admin, go to reading options. you can change the # of posts
   it shows.
 * if this is what you are asking
 *  Thread Starter [cam_oai](https://wordpress.org/support/users/cam_oai/)
 * (@cam_oai)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339035)
 * i have made a own design and like to use the loop to get the post i want.
 * i don’t think your suggestion works in my case (check my website and you know
   why)
 * / [http://www.vietzon.com](http://www.vietzon.com)
 *  [Jonathan Landrum](https://wordpress.org/support/users/jonlandrum/)
 * (@jonlandrum)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339043)
 * Well, if you’re looking to only have one post on the front page, and have, say,
   ten on your search results then you can do that with a home.php file. By default,
   WP searches for a hierarchial list of files (See Codex topic: [http://codex.wordpress.org/Template_Hierarchy](http://codex.wordpress.org/Template_Hierarchy)
   Template Hierarchy). Basically, the way you do it is to make a home.php file (
   if your theme doesn’t already have one), and change this line:
 * `<?php get_header(); ?>`
 * to this:
 * `<?php get_header(); query_posts('posts_per_page=1'); ?>`
 * That will make only one post display on the home page, but as many as you have
   selected in your options on every other page.
 * ~Jonathan
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339047)
 * cam_oai,
    you mean you want one certain post (=always the same?) to be shown 
   somewhere on your main page? If yes, use this plugin: [http://guff.szub.net/2005/01/27/get-a-post/](http://guff.szub.net/2005/01/27/get-a-post/)
 *  Thread Starter [cam_oai](https://wordpress.org/support/users/cam_oai/)
 * (@cam_oai)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339050)
 * no, not 1page in front page. i am looking for att code that pull out the specific
   post from database by using ID.
 * <?php query_posts(‘postID=40’) ?> then it will get the post 40 (that code is 
   not correct)
 * i should be simple right? i know i can get 5latest post in specific cat, so why
   can i get 1 post by ID?
 * *edit* yes Moshu, exactly what i ment. can i apply it without plugin?
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339052)
 * That’s exactly what that plugin does. Read before reposting 😉
 *  [the_rob](https://wordpress.org/support/users/the_rob/)
 * (@the_rob)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339054)
 * Along similar lines, I’m looking for the code that calls the most recent post
   w/comments to a specific page. I do not want a static post, but just the most
   recent to appear with comments. Any suggestions?
 *  Thread Starter [cam_oai](https://wordpress.org/support/users/cam_oai/)
 * (@cam_oai)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339055)
 * thankx Moshu :), i will try it then.
 * Rob, have you ever thought about the space? i mean the post and the comments 
   will take a lot of space in website right?
 *  [the_rob](https://wordpress.org/support/users/the_rob/)
 * (@the_rob)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339056)
 * Yeah. Actually I want to call the most recent post to a single page and not the
   index.php. Essentially, each time I click ‘recent post’ link (theoretically) 
   it will show the post and comments. there would only be one post on that specific
   page
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339483)
 * “_I’m looking for the code that calls the most recent post w/comments to a specific
   page._“
 * I’ve received several requests to have Get-a-Post default to the latest post.
   And now it does (that is the just released version R1.2 of the plugin does).
 * [http://guff.szub.net/2005/01/27/get-a-post/#update-20060303](http://guff.szub.net/2005/01/27/get-a-post/#update-20060303)
 * To display comments using it, try adding this to the template before calling 
   comments_template() in it:
 * `<?php $wp_query->is_single = true; ?>`
 * That is, if this is not just a [Page template](http://codex.wordpress.org/Pages#Page_Templates),
   in which case it should work without the above $wp_query code.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘get 1 post only’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 6 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [20 years, 2 months ago](https://wordpress.org/support/topic/get-1-post-only/#post-339483)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
