• Thanks in advance to your responses.

    In WP 2.5 I’m trying to build something for a client where I want him to be able to edit most parts of the content via the manage > edit > pages and posts. Most pages will have a primary content column, then another column with tertiary information. I want him to be able to edit both parts of the content. I am also using custom permalinks with it set so that the page title becomes the URL %posttitle%(blahblah.com/my-page-title)

    So I have created a file called detail_page_a.php and at the top is:

    <?php
    /*
    Template Name: detail_page_a
    */
    ?>

    and that works fine and shows up in the admin as a template choice. Now I want a specific post to show up in the left column. This is where the hang-up starts. For the life of me, poking around the WP docs I can’t find the solution. I tried some plugin called get-a-post but that didnt work.

    Any clues?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Retrieve a particular posts (where 5 is the post ID):

    query_posts('p=5');

    https://codex.www.ads-software.com/Template_Tags/query_posts

    Thread Starter robinrowell88

    (@robinrowell88)

    Thanks Greenshady. When I use

    <?php // retrieve one post with an ID of 1
    query_posts('p=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h4><?php the_title(); ?></h4>
    <?php the_content(); ?>
    <?php endwhile;?>

    it won’t work. I have 3 posts, and the only one it seems to work with is if I make p=0, 1 and 2 don’t. All 3 are set to uncategorized.

    ???

    You should be more specific about “won’t work.” That means absolutely nothing when talking about code.

    This works perfectly fine:

    <?php /*
    Template Name: Query Single Post
    */
    get_header(); ?>
    	<?php query_posts('p=40'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    		<h4><?php the_title(); ?></h4>
    		<?php the_content(); ?>
    	<?php endwhile;?>
    <?php get_footer(); ?>

    I found a post. The one I picked had an ID of 40. So, I set p=40. On the page I chose to use this on, I selected the “Query Single Post” post template. Clicked save and refreshed my page.

    I have this code on my template:

    <?php $recent = new WP_Query("cat=36&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
    			<a href="<?php the_permalink() ?>" rel="bookmark"><img style="padding:5px 0px 2px 0px;" src="<?php echo get_post_meta($post->ID, "right feature", true); ?>" alt="<?php echo get_post_meta($post->ID, "Theme Name", true); ?> Thumbnail" /></a>
    			<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    			<?php the_content_limit(175, "[Read More]"); ?>
    			<?php endwhile; ?><br />

    Now, this shows the last recent post from a given category, with an image above it and a short intro of that post. (right feature is the image code on custom fields) Instead of this, I want it to show only the post ID i decide to, and not to change each time there is a new post in that given category. What should I change on the query in order to do this?

    Thanks!

    I use this

    <?php
    // retrieve one post with an ID of 5
    query_posts('p=1');
    
    global $more;
    $more = 0;
    
    // the Loop
    while (have_posts()) : the_post();
      // the content of the post
      the_content('Read the full post ?');
    endwhile;
    ?>

    but still the more link is not working any ideas ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Display A Specific Post in a Page Template?’ is closed to new replies.