• I’m building a hybrid site that has static html pages as well as a wordpress-blog section. The front page of the site is html, but I want to a div with the newest post in it as an enticement to go to the blog section. Anyway, I can’t figure out how to set up a “call” for the newest post & it’s title. Is there someone out there who knows how this is done? Thanks! by the way, wordpress is in the directory “/blog/” if that helps. Thanks!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have a look at Creating_a_Static_Front_Page. In particular, the integration and mini-loop sections might be helpful.

    Thread Starter jakepaint

    (@jakepaint)

    Perfect. The mini-loop was the ticket. This solution will create a list with the most recent posts’ titles. Could you tell me how to also add the first line or two of the actual post? I tried to do it myself in the php code, but I couldn’t figure out how to make it work.

    Try adding the_excerpt in your mini-loop.

    Similar to the examples you see for The_Loop, just replacing the_content with the_excerpt.

    Hope that made sense…

    Thread Starter jakepaint

    (@jakepaint)

    I guess that was kind of over my head. Here’s what I’ve got:

    <?php
    $how_many=2; //How many posts do you want to show
    require_once("blog/wp-config.php"); // Change this for your path to wp-config.php file ?>
    <ul 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 ("
    <li><a>%s</a></li>
    ", $np->ID,$np->post_title);
    }?>

    Where do I add in the the_excerpt?

    Ah. oops. THAT sort of loop…

    Unfortunately, that negates use of the_excerpt tag I think. We’ll need to wait for one of the brighter folks to spot this and help out. :-\

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Calling new post “teaser” in html page’ is closed to new replies.