我创建了一个最近的帖子类型插件,它显示了另一个网站最近的帖子,但永久链接不能正常工作。永久链接不显示帖子的URL,它显示相同的网站URL。有人能帮我吗?
这是我自己的代码:
// db parameters
$db_hostname = \'localhost\';
$db_username = \'root\';
$db_password = \'\';
$db_database = \'blog\';
// Base folder for the blog. Make SURE there is a slash at the end
$blog_url = \'http://localhost/site/blog/\';
// Connect to the database
mysql_connect( localhost, $db_username, $db_password );
@mysql_select_db( $db_database ) or die( "Unable to select database" );
// Get data from database
// IMPORTANT, the "LIMIT 5" means how many posts will appear. Change 5 to any whole number.
$query = "Select * FROM wp_posts WHERE post_type=\'post\' AND post_status=\'publish\'
ORDER BY id DESC LIMIT 5";
$query_result = mysql_query( $query );
$num_rows = mysql_numrows( $query_result );
// Close database connection
mysql_close();
require_once( ABSPATH . \'/blog/wp-load.php\' );
$args = array(
\'post_status\' => \'publish\',
\'post_type\' => \'post\',
\'posts_per_page\' => 5
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
?>
<h1>"><?php the_title() ?></h1>
<?php if ( has_post_thumbnail() ) : ?>
" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail( \'featured-thumbnail\' ) ?>
<?php the_excerpt() ?>
<?php the_time( \'M j, Y\' ) ?>
<?php ?>
<?php
endif;
endwhile;