Title: Single post!
Last modified: August 21, 2016

---

# Single post!

 *  [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/)
 * Complex logic of WP continues to elude me.
 * I need to display one single post (title and content) on a page. File “single.
   php” is supposedly dedicated for this. So, when user goes to page “site.com/p
   =85”, he should see the post with id of 85. And that’s all! Only ONE post.
 * If I’m insterting “the loop” in this page, ALL posts are listed.
 * If I’m not inserting “the loop”, I cannot access “the_title()”, “the_content()”,
   and other post data.
 * How I am to display single post in single.php ? ALL examples of single.php on
   the Internet for some unknown reason include “the loop”, and all of them display
   ALL posts! Why ??
 * How I am to get current post and it’s data (title, content) that should be displayed
   according to the current URI “/p=85” ???

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

 *  [kjodle](https://wordpress.org/support/users/kjodle/)
 * (@kjodle)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790591)
 * Which theme are you using? Please post a link to your site.
 *  [Kevin Pryce](https://wordpress.org/support/users/kpry44/)
 * (@kpry44)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790614)
 * Just use
 * `the_post();`
 * You don’t need to loop as you are already on single.php.
 *  Thread Starter [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790618)
 * I’m building my own theme.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790636)
 * the link should be:
 * `/?p=85`
 * a wrong link might just get to use the index.php template if your theme does 
   not have a 404 template (?)
 * does your theme have a single.php?
 *  Thread Starter [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790707)
 * OK, I suppose I shoud’ve gotten into details from the start.
 * So.
    I’m making my own Theme. I need a page, that would display only one Post.
   I found that file called “single.php” is used for it.
 * So I’ve made it, here it is:
 *     ```
       <?php get_header(); ?>
   
       <?php get_sidebar(); ?>
   
         <?php the_post(); ?>
   
         <p><?php the_date(); ?>
   
         <p><?php the_category(', ') ?>
   
         <div class="thumb"><?php the_post_thumbnail(); ?></div>
   
         <p><?php the_content(); ?>
   
         <?php previous_post_link(); ?>
         <?php next_post_link(); ?>
   
         <?php the_tags(); ?>
   
       <?php get_footer(); ?>
       ```
   
 * Site url is [http://golovanov.net/biosea/](http://golovanov.net/biosea/)
 * I’ve made two test posts.
 * Post links are:
    [http://golovanov.net/biosea/?p=85](http://golovanov.net/biosea/?p=85)
   [http://golovanov.net/biosea/?p=1](http://golovanov.net/biosea/?p=1)
 * But with this “single.php” file I always get only the post with id 85 (the latest
   of them), regardless of the address – either [http://golovanov.net/biosea/?p=85](http://golovanov.net/biosea/?p=85)
   or [http://golovanov.net/biosea/?p=1](http://golovanov.net/biosea/?p=1) displaying
   only one (latest) post.
 *  Thread Starter [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790708)
 * Interestingly enough, I discovered it just now – page title in the <title> html
   tag displayed properly, depending on the post id in the URI.
    It’s done by <?
   php wp_title(); ?> function in the “header.php”.
 * But everything else is the same on this two pages, while it’s two different posts.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790716)
 * is there anything in header.php or sidebar.php that could possibly mess with 
   the original query?
 *  Thread Starter [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790717)
 * Sidebar is (excluding texts):
 *     ```
       <!-- Sidebar -->
       <tr>
         <td id="sidebar" valign="top">
           <?php
             global $post;
             switch ( get_post( $post )->post_name ) {
               default;
                 echo "<ul id='contents'>\n";
                 wp_list_pages('title_li=&sort_column=menu_order&depth=2');
                 echo "</ul>\n";
               break;
             }
           ?>
   
           <hr>
   
           <?php
             query_posts($query_string . '&post_type=post');
   
             while ( have_posts() ) : the_post();
               the_date();
               echo ' <a href="'.get_permalink().'">';
               the_title();
               echo '</a><br>';
             endwhile;
           ?>    
   
         </td>
         <td class="content" valign="top">
           <div class="content">
       <!-- /Sidebar -->
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790730)
 * after:
 * `endwhile;`
 * add:
 * `wp_reset_query();`
 *  Thread Starter [sly_g](https://wordpress.org/support/users/sly_g/)
 * (@sly_g)
 * [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790739)
 * Well, it almost helped, thanks!
 * One small problem left: date of first post doesn’t show.
    The one that should
   be where <?php the_date(); ?> is.
 * UPD:
    I found out that this could happen in a loop and when dates are the same.
   However, it’s not a loop and dates are different.
 * But with the_time(‘d.m.Y’) date is displayed correctly. Strange.

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

The topic ‘Single post!’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [single](https://wordpress.org/support/topic-tag/single/)

 * 10 replies
 * 4 participants
 * Last reply from: [sly_g](https://wordpress.org/support/users/sly_g/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/single-post-3/#post-3790739)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
