WP Help
- Started
- Last post
- 13 Responses
- trooperbill
im trying to publish the latest 5 wordpress entries on my sites home page (the blogs in /blog/)
the code ive been given is:
<p><?php /* Short and sweet */ define('WP_USE_THEMES', false); ?>
<?php require('/blog/wp-blog-header.php'); ?>
<?php query_posts('showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href=<?php the_permalink() ?>><?php the_title(); ?></a><br />
<?php endwhile;?></p>but it doesnt work :(
- trooperbill0
*bump*
help meeeeee plz :)
- jamble0
Is your site homepage part of your wordpress install?
- bulletfactory0
link? can we see the error?
looks correct to me, here's the gist of mine...
<?php if (have_posts()) : ?>
<?php query_posts('showposts=4'); ?>
<?php while (have_posts()) : the_post();
<h3><?php the_title() ?></h3><?php endwhile; ?>
<?php else : ?>
<?php endif; ?>- < -- sorry, i left out the closing tag on " :the_post();"bulletfactory
- jar0
i don't see why it shouldn't work. this is how i've done it for most sites.
<?php $newsPosts = new WP_Query();
$newsPosts->query('showposts=5&cat=6');
?><?php while ($newsPosts->have_posts()) : $newsPosts->the_post(); ?>
<h2>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h2><?php endwhile; ?>
- acescence0
WP_USE_THEMES is for bypassing the WP theme system in the root index.php file, are you putting this in a theme file?
- trooperbill0
the sites www.chesterfield-sofa.co.uk, im no php guy which is why im struggling lol. the blog is in
/blog/
but i want the latest posts on the home page
- acescence0
put this at the top of your page to turn on php error reporting and see what you get..
<?php
error_reporting("E_ALL");
ini_set("display_errors", "1");
?>
- acescence0
oh, wait, i think i know what it is. the path to blog header has to be the path on the server's internal filesystem, not the web path. something like /var/www/html/blog/wp-blog-heade...
if this is just being used on the front page, you can make it relative..
'./blog/wp-blog-header.php'
note the dot in front.
- trooperbill0
ok thanks ill try it tomorrow.
- trooperbill0
using this code:
<p><?php /* Short and sweet */ define('WP_USE_THEMES', false); ?>
<?php require('./blog/wp-blog-header.php'); ?>
<?php query_posts('showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a><br />
<?php endwhile;?></p>i get the error:
Parse error: syntax error, unexpected '.', expecting '(' in /home/sites/chesterfield-sofa.co... on line 64
- neverblink0
so... what's on line 64?
- trooperbill0
lol its a plug in that doesnt like it so ive removed the plugin and it works... thanks guys.
- rodzilla0
sofa-king wordpress