• 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 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)
  • 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

    (@deaftone)

    <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?

    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

    (@deaftone)

    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 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

    (@deaftone)

    Oh right, so just ul instead of ol! Simple enough, but what about the other customizations? Is just that impossible for a newbie?

    er ok nevermind man it would help if i could read. *outside* of wordpress… let me start all over

    Thread Starter deaftone

    (@deaftone)

    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, the mini-loop below the logo and menu looks horrible and the type they have in http://www.dreamten.com would definitely look alot better lol!

    <?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>

    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

    (@deaftone)

    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

    Thread Starter deaftone

    (@deaftone)

    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.

    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

    (@deaftone)

    Might need a few minutes, not sure how to activate permalinks! lol!

    Settings > Permalinks

    I think…

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

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