I have created a recent post type plugin and it displays recent posts from another website, but the permalinks are not working properly. The permalink does not show the post's URL, it shows the same website URL. Can anyone help me?
Here is my own code:
// 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;