Solved

How do i display a specific post in word press

Posted on 2008-06-18
8
258 Views
Last Modified: 2010-03-31
I am using a revolution theme in my wordpress blog and would like to be able to display the exact post i want . I have tried the code in wordpress help sections but it doesn’t work and i get syntax error on the page.
0
Comment
Question by:dkj13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 15

Expert Comment

by:dosth
ID: 21819660
0
 

Author Comment

by:dkj13
ID: 21825290
i tried that i get a syntax error when i place the code into the template.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 21826275
>>i tried that i get a syntax error when i place the code into the template.
can you post the code and the error

you need to make the call just before the loop

<?php
// retrieve one post with an ID of 5
query_posts('p=5');      
?>
<!-- the loop -->
<?php if (have_posts()) : ?>
      <?php while (have_posts()) : the_post(); ?>
      <?php require('post.php'); ?>
<?php endwhile; ?>

            <div class="navigation">
                  <div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
                  <div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
            </div>
            
      <?php else : ?>

      <?php endif; ?>
0
Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

 
LVL 15

Expert Comment

by:dosth
ID: 21828796
give us the url so we can go from there
0
 

Author Comment

by:dkj13
ID: 21838099
The URL is opinionscouts.com/reviews.  HERE IS THE CODE I HAVE IN THERE, I CAN GET IT TO GET A RANDOM POST BUT NOT THE EXACT POST I WANT.

BELOW IS THE CODE I USE TO GET THE EXACT POST I WANT IN THE FEATURED SECTION ON HOME PAGE LEFT, BUT IT WILL NOT WORK IN FEATURED CATEGORY FOR SOME REASON.

<div id="homepageleft">
            
                  <div class="featured">
                        <?php query_posts('p=6'); while (have_posts()) : the_post(); ?>
                        <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                        <?php global $more; $more = 0; the_content(__('Find out more &raquo;'));?><div style="clear:both;"></div>
                        <?php endwhile; ?>
                  </div>
<div id="homepageright">
		
			<div class="thumb">
			<h2>Featured Category #1</h2>
 
				<?php $rand_posts = get_posts('numberposts=&orderby=RAND()'); foreach( $rand_posts as $post )?>
 
				<div class="thumbleft">
					<a href="http://healthy13.surveysc.hop.clickbank.net">
<img src="http://opinionscouts.com/reviews/wp-content/themes/revolution_magazine-21/images/girls.jpg"></a>
				</div>
				
				<div class="thumbright">
					<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
					
					<?php global $more; $more = 0; the_content(__('Find out more &raquo;'));?>
				</div>
				
				<div style="clear:both;"></div>
				
				
				
			</div>
		
			<div class="thumb">
			<h2>Featured Category #2</h2>
 
				<?php $rand_posts = get_posts('numberposts=&orderby=RAND()'); foreach( $rand_posts as $post )?>
 
				<div class="thumbleft">
					<a href="http://healthy13.surveysc.hop.clickbank.net">
<img src="http://opinionscouts.com/reviews/wp-content/themes/revolution_magazine-21/images/compsm.jpg"></a>
				</div>
				
				<div class="thumbright">
					<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
					
					<?php global $more; $more = 0; the_content(__('Find out more &raquo;'));?>
				</div>
				
				<div style="clear:both;"></div>
				
				
				
			</div>
		

Open in new window

0
 
LVL 15

Expert Comment

by:dosth
ID: 21844186
can you try some thing like Jester said

<div class="featured">
                    <?php
                  // retrieve one post with an ID of 5
                  query_posts('p=6');      
                  ?>
                  <?php if (have_posts()) : ?>
                        <?php while (have_posts()) : the_post(); ?>
                        <?php require('post.php'); ?>
                  <?php endwhile; ?>                        
                        <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                        <?php global $more; $more = 0; the_content(__('Find out more &raquo;'));?><div style="clear:both;"></div>
                  </div>
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 125 total points
ID: 21845284
don use get_posts
from the wp website

Template Tags/get posts
Description
This is a simple tag for creating multiple loops.

Template Tags/query posts
Query_posts can be used to control which posts show up in The Loop. It accepts a variety of parameters in the same format as used in your URL. (e.g. p=4 to show only post of ID number 4)

you should be using query not get
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Moving to a new hosting provider 8 45
if (is_singular not working 5 50
WordPress Page Content Lost 2 50
wordpress 4.7.4, theme 8 41
WordPress has made it easy to create scalable sites based on their powerful CMS, but as great as WordPress is, there are some SEO issues that haven’t been addressed out of the box.  Fortunately these problems can be solved with a few plugins.  The f…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question