Old 23-03-2007, 09:08   #1 (permalink)
dpc036
Senior Member
 
dpc036's Avatar
 
Join Date: May 2005
Location: St Helens
Posts: 473
Wordpress Users gis a hand

ive created a static homepage, home.php with my menu on it.
i need to link to my posts from the main menu, so the index.php page.

ive posted on the wordpress forum but its like a ghost town over there!
how do i do this?
  Reply With Quote
Old 23-03-2007, 09:43   #2 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 7,000
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
Code:
<?php define('WP_USE_THEMES', false); require('path/to/wp-blog-header.php'); $how_many=2; //How many posts do you want to show require_once("path/to/wp-config.php"); $news=$wpdb->get_results("SELECT `ID`,`post_title`, `post_excerpt` FROM $wpdb->posts WHERE `post_status`= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many); foreach($news as $np){ //NOTE: get other post data by selecting different //data in the posts table... $permalink=get_permalink($np->ID); $html= "<a href=\"". $permalink ."\">$np->post_title</a>\n"; //NOTE: you can easily alter the HTML above to suit echo $html; } ?>

something like this?
__________________
  Reply With Quote
Old 23-03-2007, 09:58   #3 (permalink)
dpc036
Senior Member
 
dpc036's Avatar
 
Join Date: May 2005
Location: St Helens
Posts: 473
emil thanks for that.
i thought there would be a easier way (for me) to do this, as the index.php is already setup to display the posts. But because i have a home.php that gets called first.
  Reply With Quote
Old 23-03-2007, 09:59   #4 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 7,000
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
So you want to dsiplay your posts in your home.php?

You can use the same code that I gave you, just edit the html to match your loop.

I have nicked that code from the wordpress support forums if I remember correctly.
__________________
  Reply With Quote
Old 23-03-2007, 10:19   #5 (permalink)
dpc036
Senior Member
 
dpc036's Avatar
 
Join Date: May 2005
Location: St Helens
Posts: 473
i want it setup so i have a static front page with no posts.
then when you click "blog" you go to the posts page.

it seems like it should be a simple thing to do, and probably is, but im not able to do it.
  Reply With Quote
Old 23-03-2007, 10:40   #6 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 7,000
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
__________________
  Reply With Quote
Old 23-03-2007, 10:44   #7 (permalink)
dpc036
Senior Member
 
dpc036's Avatar
 
Join Date: May 2005
Location: St Helens
Posts: 473
yep.
and with the new version of wordpress you can select a page to become the home page.

but i seem to be missing how to link from the home page to the posts.
  Reply With Quote
Old 23-03-2007, 10:46   #8 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 7,000
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
I have no idea then I'll get my coat.
__________________
  Reply With Quote
Old 23-03-2007, 10:55   #9 (permalink)
dpc036
Senior Member
 
dpc036's Avatar
 
Join Date: May 2005
Location: St Helens
Posts: 473
thanks anyway
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8