Title: Altering a mini loop and PHP
Last modified: August 18, 2016

---

# Altering a mini loop and PHP

 *  [kri](https://wordpress.org/support/users/kri/)
 * (@kri)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/altering-a-mini-loop-and-php/)
 * I have a static front page, with a sort of mini-loop showing news posts on our
   site. I want to be able to make a post set with a future post date in the timestamp,
   which works fine every where else. It doesn’t work in the mini-loop because that
   takes all posts that have been published (regardless of date).
 * Here is the code we’re using…
 * `<?php
    # Here starts Mini Loop $how_many=8; //How many posts do you want to 
   show
 * function niceDate($s) { return strftime("%A %e %B %Y", strtotime($s)); }
    function
   extrac($s) { return substr(strip_tags($s),0,100); } $news=$wpdb->get_results("
   SELECT DISTINCT $wpdb->posts.ID as ID, $wpdb->posts.post_title AS post_title,
   $wpdb->posts.post_date AS date, $wpdb->posts.post_content AS text FROM $wpdb-
   >posts LEFT OUTER JOIN $wpdb->post2cat ON $wpdb->posts.ID = $wpdb->post2cat.post_id
   WHERE $wpdb->posts.post_status = \"publish\" AND NOT ($wpdb->post2cat.category_id
   = 3 OR $wpdb->post2cat.category_id = 10) ORDER BY ID DESC LIMIT ".$how_many);
   foreach($news as $np){ printf ("<span class='extract'>%s</span><br/>%s<br/><span
   class='extract'>%s...</span><br/> <br/>", niceDate($np->date),$np->ID,$np->post_title,
   extrac($np->text));
 * I think what we’ll need to do is take this code _WHERE $wpdb->posts.post\_status
   = \”publish\” AND NOT ($wpdb->post2cat.category\_id = 3 OR $wpdb->post2cat.category\
   _id = 10)_ and add another exception to it. However, I’m not familiar enough 
   with PHP to do this myself.
 * Is anyone willing to lend their skills to this problem for me?

The topic ‘Altering a mini loop and PHP’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 0 replies
 * 1 participant
 * Last reply from: [kri](https://wordpress.org/support/users/kri/)
 * Last activity: [19 years, 10 months ago](https://wordpress.org/support/topic/altering-a-mini-loop-and-php/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
