Title: PhP import question.
Last modified: August 19, 2016

---

# PhP import question.

 *  [cutaia](https://wordpress.org/support/users/cutaia/)
 * (@cutaia)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/php-import-question/)
 * Hello there. I have a question about whether something is possible. I have the
   following code importing my most recent blog entries to another page on my website.
   It works great, except, I’ve recently started using wordpress “pages” for a different
   type of article. I was able to stop these pages from showing up directly in the
   blog itself, but they are still importing to my site along with regular “blog”
   entries. I was wondering if there’s something I can add to this code that will
   make it ignore “pages” while continuing to import “blog entries.”
 * I’m assuming (or at least hoping) that it’s as simple as inserting another parameter
   into this line: $result = mysql_query(“SELECT * FROM wp_posts WHERE post_status
   =’publish’ ORDER BY id DESC LIMIT 0,4”);
 * Thanks in advance for any help.
 * ————————————————————————-
 *     ```
       <?php
       $dbh=mysql_connect ("***********", "***********", "**********");
       mysql_select_db ("************");
       $result = mysql_query("SELECT * FROM wp_posts WHERE post_status='publish' ORDER BY id DESC LIMIT 0,4");
       while($row = mysql_fetch_array($result))
         {
       $title = $row[post_title];
       $content = $row[post_content];
       $id = $row[ID];
       $date = $row[post_date];
       $chars = preg_split('/ /', $date);
       $splitdate = $chars[0];
       $breakdate = preg_split('/-/', $splitdate);
       $year = $breakdate[0]; //This is the year
       //create arrays
       $monthfind = array ('/01/', '/02/', '/03/', '/04/', '/05/', '/06/', '/07/', '/08/', '/09/', '/10/', '/11/', '/12/', );
       $monthsreplace = array ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12',  );
       $month = $breakdate[1];
       ?>
   
       <h4><a href="<?php echo $row[guid]; ?>"><?php echo $title; ?></a></h4>
       <hr /><br />
       <?php
       if (preg_match("/<param/", $content))
       {
       echo $content;
       }
       else
       {
       echo nl2br($content);
       }
       echo "<h6>Posted ";
       Echo preg_replace ($monthfind, $monthsreplace, $month);
       echo ".";
       echo $breakdate[2];
       echo ".10</h6>";
       ?>
   
       <?php
       }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [cutaia](https://wordpress.org/support/users/cutaia/)
 * (@cutaia)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/php-import-question/#post-1573118)
 * Somehow I managed to figure it out myself! 😀
 * I changed that line to this: (“SELECT * FROM wp_posts WHERE post_status=’publish’**&&
   post_type!=’page’** ORDER BY id DESC LIMIT 0,4″)
 * Can a moderator please mark this as resolved? Thanks in advance. 🙂

Viewing 1 replies (of 1 total)

The topic ‘PhP import question.’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [cutaia](https://wordpress.org/support/users/cutaia/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/php-import-question/#post-1573118)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
