Forums

Static Splash Page: Loop Coding Problems (3 posts)

  1. idlan
    Member
    Posted 3 years ago #

    The setup is as follows:

    I have a static intro page, where I would like to show the latest entries from two WP powered blogs currently on my server. I have used the code from http://codex.wordpress.org/Creating_a_Static_Front_Page. Because I need to call from two different wp-config.php files, I modified the require_once() command to include(path/to/wp-config.php). This is shown in the code below. However what has happened is that I get the latest entry from only one blog - you can see this here: http://www.idlanzakaria.com/home.php

    I am very sure the correction is very minor, but I am a total PHP novice, and am totally stuck. I'd be grateful for any and all pointers.

    Here is the code I used:

    <?php
    $how_many=5; //How many posts do you want to show
    include("/home/idlanzak/public_html/conversed/wp-config.php"); // Change this for your path to wp-config.php file ?>
    <ol id="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. %s
  3. ", $np->ID,$np->post_title);
    }?>

    <?php
    $how_many=5; //How many posts do you want to show
    include("/home/idlanzak/public_html/wordpress/wp-config.php"); // Change this for your path to wp-config.php file ?>
    <ol id="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){
    print ("

  4. <a href=\"");
    echo get_permalink($np->ID);
    print ("\">$np->post_title
  5. ");
    } ?>

  • forumozel
    Member
    Posted 3 years ago #

  • roccanet
    Member
    Posted 3 years ago #

    I have created a tutorial to get post excerpts published to any web page with a built in cache - i also had a very hard time getting the loop to do what i wanted and did not like that every time i got a post hit my DB would get a call...hope this might help`

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags