• I have create a recent post type plugin and it display recent post from another website but there is some problem with permalink.
    the permalink is not working properly
    So anyone can help me pls………..
    there is my own code

    //db parameters
    $db_hostname = ‘localhost’;
    $db_username = ‘root’;
    $db_password = ”;
    $db_database = ‘blog’;

    $blog_url = ‘https://localhost/site/blog/’; //base folder for the blog. Make SURE there is a slash at the end

    //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 the 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;

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘how to display recent posts from wordpress database to another wordpress site’ is closed to new replies.