如何在php中创建wordpress固定链接[关闭]

I have a php page where I am getting latest blog posts from db like this

$result = mysql_query("SELECT * FROM wp_posts ORDER BY ID DESC LIMIT 3")ordie(mysql_error());

Now from here I want to redirect to actual wordpress post

<a href="#" target="_blank"><?php echo $row->post_title; ?></a>

How do I get the permalink? any help? thanks in advance

Wordpress generates your URLs instead of storing them,

try this query from Dave Heavy Industries

SELECT wpp.post_title, wpp.guid, wpp.post_date, CONCAT(wpo_su.option_value, REPLACE( REPLACE( REPLACE( REPLACE(wpo.option_value,'%year%',date_format(wpp.post_date,'%Y')) ,'%monthnum%',date_format(wpp.post_date,'%m')) ,'%day%',date_format(wpp.post_date,'%d')) ,'%postname%',wpp.post_name ) ) as permalink FROM wp_posts wpp INNER JOIN wp_options wpo on wpo.option_name='permalink_structure' and wpo.blog_id=0 INNER JOIN wp_options wpo_su on wpo_su.option_name='siteurl' and wpo_su.blog_id=wpo.blog_id WHERE wpp.post_type = 'post' AND wpp.post_status = 'publish' ORDER BY wpp.post_date DESC 

then you can get the link like

<a href="<?php echo $row->permalink; ?>" target="_blank"><?php echo $row->post_title; ?></a>

I don't know what the WP tables look like (there might be some kind of permalink in there), but something like yoursite.com/?p=XX, where XX is the post ID, should work.