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.”
(Here’s hoping I get this code into this post correctly)
————————————————————————-
<?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 } ?> -
You did not specify a blog address or reason for posting when you created this topic.
This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.
If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.
If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.
This is an automated message.
-
Eh…I just noticed this supportbot notice that says I should post on wordpress.org. Sorry for the inconvenience. Please delete this post moderators.
- The topic ‘PhP import question.’ is closed to new replies.