WordPress.org

Ready to get started?Download WordPress

Forums

Help with Headlines (1 post)

  1. Graphics
    Member
    Posted 9 years ago #

    This might get confusing, but bear with me:

    I wanted a headlines list on my homepage (static, HTML)

    I found the php code for a Mini-loop.

    Now, I can't put php into my html homepage, so I got a little creative-
    I made a page with the loop in it, saved as php, and <IFRAMED> the new page into the homepage.

    This works great, but with 2 exceptions:
    1) the list of headlines is justified as "center" and needs to be"left"
    2) (and most importantly) The links open in the IFRAME and need to open in a new window (i.e. - target="_new")

    Here is the php for the loop so far:

    <td>
    <?php define('WP_USE_THEMES', false);
    require('./wordpress/wp-blog-header.php');
    ?>
    <div id="content" class="narrowcolumn">

    <h2>Lastest Posts:</h2>

    <?php
    # Here starts Mini Loop trick: You can use this code, but _at your own risk_
    # If you want to improve this code, you're welcome ;)

    $how_many=7; //How many posts do you want to show ?>
    <ul class="whats-new">
    <?
    $news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
    WHERE post_status = \"publish\" ORDER BY ID DESC LIMIT ".$how_many);
    foreach($news as $np){
    printf ("

  2. href=\"bloghome.htm?p=%s\">%s
  3. ", $np->ID,$np->post_title);
    }?>

    </div>

    </td>

    NOTE: had to pull " tags this time either!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.