Title: Mini-loop
Last modified: August 19, 2016

---

# Mini-loop

 *  [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/)
 * I read up on the info provided by codex on how to setup a mini loop on a page
   outside of wordpress and that’s working fine, but im having such a hard time.
   This is the code im using:
 *     ```
       <?php
       $how_many=5; //How many posts do you want to show
       require_once('domains/news.deaf-monkey.com/html/wp-config.php'); // Change this for your path to wp-config.php file ?>
   
       <ol id="whats-new">
       <?
       $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
       WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
       foreach($news as $np){
       printf ("<li><a href=\"http://news.deaf-monkey.com/index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
       }?>
       </ol>
       ```
   
 * But the problem im having is whenever i try to modify it i just end up messing
   it up, i was wondering if anyone could help me customize it in such a way that
   i can remove the way it uses a numbering system to display the posts. To make
   it easier i think the latest blog posts section at the bottom of [http://www.dreamten.com](http://www.dreamten.com)
   is exactly how i want my mini-loop to look like, which shows the date, comments
   and even the small 1px margins separating each post.

Viewing 15 replies - 1 through 15 (of 24 total)

1 [2](https://wordpress.org/support/topic/mini-loop/page/2/?output_format=md) [→](https://wordpress.org/support/topic/mini-loop/page/2/?output_format=md)

 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942206)
 * That looks way more complicated than it should be, I think. Can you show me where
   in the codex you found that?
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942208)
 * Here it is bekabug, [http://codex.wordpress.org/Creating_a_Static_Front_Page#Integrating_WordPress](http://codex.wordpress.org/Creating_a_Static_Front_Page#Integrating_WordPress)
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942209)
 *     ```
       <ul class="recent">
       <?php $the_query = new WP_Query('showposts=5&orderby=post_date&order=desc');
   
       while ($the_query->have_posts()) : $the_query->the_post();
   
       $do_not_duplicate = $post->ID; ?>
   
       <li><a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title(); ?>"><?php echo strip_tags(get_the_title(), '<a>'); ?></a></li>
   
       <?php endwhile; ?>
       </ul>
       ```
   
 * Does that look a little easier to swallow?
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942211)
 * the ordered list tag in your code you posted is what is numbering it. if you 
   change that to an unordered list you’ll get bullets instead of numbers…but that
   query looks way too complicated.
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942212)
 * I think i might have not made myself clear enough in my first post, im not having
   a problem with the code in it’s normal state, everything working for me, it’s
   just that im having trouble customizing it into something like what [http://www.dreamten.com](http://www.dreamten.com)
   did in their latest blog posts section at the bottom of the frontpage, showing
   the comments made on the latest posts, the date of the posts and etc. etc. I 
   just want to modify
 *     ```
       <?php
       $how_many=5; //How many posts do you want to show
       require_once('domains/news.deaf-monkey.com/html/wp-config.php'); // Change this for your path to wp-config.php file ?>
   
       <ol id="whats-new">
       <?
       $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
       WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
       foreach($news as $np){
       printf ("<li><a href=\"http://news.deaf-monkey.com/index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
       }?>
       </ol>
       ```
   
 * To suit my site’s front page as it currently displays my latest posts in this
   way:
 * “1. Post
    2. Post 2 3. Post 3″
 * Hope i didn’t just confuse things hahah.
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942213)
 * Oh right, so just ul instead of ol! Simple enough, but what about the other customizations?
   Is just that impossible for a newbie?
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942214)
 * er ok nevermind man it would help if i could read. *outside* of wordpress… let
   me start all over
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942217)
 * Hahaha, it’s all good man, im sorry if i seem a bit lost when it comes to this,
   really bad at coding, but fortunately this is the last thing i wanna do for my
   site! Hahah, as you can see from [http://www.deaf-monkey.com](http://www.deaf-monkey.com),
   the mini-loop below the logo and menu looks horrible and the type they have in
   [http://www.dreamten.com](http://www.dreamten.com) would definitely look alot
   better lol!
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942221)
 *     ```
       <?php
       $how_many=5; //How many posts do you want to show
       require_once('domains/news.deaf-monkey.com/html/wp-config.php'); // Change this for your path to wp-config.php file ?>
   
       <ul id="whats-new">
       <?
       $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code>,<code>comment_count</code>,<code>post_date</code> FROM $wpdb->posts
       WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
       foreach($news as $np){
       printf ("<li><a href=\"%s\">%s</a> Posted: %s Comments: %s</li>", get_permalink($np->ID),$np->post_title,$np->post_date,$np->comment_count);
       } ?>
       </ul>
       ```
   
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942222)
 * geeze…the forum is trashing the code… all code tags need to be backtics `
 * let me know if that works out for you
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942224)
 * i used this:
 *     ```
       <?php
       $how_many=5; //How many posts do you want to show
       require_once('/nfs/c03/h04/mnt/57867/domains/news.deaf-monkey.com/html/wp-config.php'); // Change this for your path to wp-config.php file ?>
   
       <ul id="whats-new">
       <?
       $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code>,<code>comment_count</code>,<code>post_date</code> FROM $wpdb->posts
       WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
       foreach($news as $np){
       printf ("<li><a href=\"%s\">%s</a> Posted: %s Comments: %s</li>", get_permalink($np->ID),$np->post_title,$np->post_date,$np->comment_count);
       } ?>
       </ul>
       ```
   
 * as you suggested and i ended up with blanks instead. just check [http://www.deaf-monkey.com](http://www.deaf-monkey.com)
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942225)
 * Ah, i added the url in the printf section instead of:
 *     ```
       printf ("<li><a href=\"%s\">%s</a> Posted: %s Comments: %s</li>", get_permalink($np->ID),$np->post_title,$np->post_date,$np->comment_count);
       } ?>
       ```
   
 * as you suggested, i added and made it:
 *     ```
       <?php
       $how_many=5; //How many posts do you want to show
       require_once('/nfs/c03/h04/mnt/57867/domains/news.deaf-monkey.com/html/wp-config.php'); // Change this for your path to wp-config.php file ?>
   
       <ul id="whats-new">
       <?
       $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code>,<code>comment_count</code>,<code>post_date</code> FROM $wpdb->posts
       WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
       foreach($news as $np){
       printf ("<li><a href=\"http://news.deaf-monkey.com/index.php?p=%s\">%s</a> Posted: %s Comments: %s</li>", get_permalink($np->ID),$np->post_title,$np->post_date,$np->comment_count);
       } ?>
       </ul>
       ```
   
 * **BUT** it still isn’t showing any thing.
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942231)
 * ah! you’re not using permalinks. can you turn those on and then try my code without
   you manually putting the URL in there.
 *  Thread Starter [deaftone](https://wordpress.org/support/users/deaftone/)
 * (@deaftone)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942234)
 * Might need a few minutes, not sure how to activate permalinks! lol!
 *  [bekabug](https://wordpress.org/support/users/bekabug/)
 * (@bekabug)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/#post-942235)
 * Settings > Permalinks
 * I think…

Viewing 15 replies - 1 through 15 (of 24 total)

1 [2](https://wordpress.org/support/topic/mini-loop/page/2/?output_format=md) [→](https://wordpress.org/support/topic/mini-loop/page/2/?output_format=md)

The topic ‘Mini-loop’ is closed to new replies.

 * 24 replies
 * 2 participants
 * Last reply from: [deaftone](https://wordpress.org/support/users/deaftone/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/mini-loop/page/2/#post-942302)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
