Support » Fixing WordPress » Mini Loop outside wordpress directory

  • Hi,

    I have seen the codex page http://codex.wordpress.org/The_Loop_in_Action#Excerpts_Only

    and I think this is what I need….

    I have static page outside the wordpress directory e.g.

    RESOURCES
         index.html
         WORDPRESS

    so that I can get a small excerpt about 100 words on the static index page, I seen this code..

    <?php if (have_posts()) : ?>
    
      <?php if (($wp_query->post_count) > 1) : ?>
         <?php while (have_posts()) : the_post(); ?>
           <!-- Do your post header stuff here for excerpts-->
              <?php the_excerpt() ?>
           <!-- Do your post footer stuff here for excerpts-->
         <?php endwhile; ?>
    
      <?php else : ?>
    
         <?php while (have_posts()) : the_post(); ?>
           <!-- Do your post header stuff here for single post-->
              <?php the_content() ?>
           <!-- Do your post footer stuff here for single post-->
         <?php endwhile; ?>
    
      <?php endif; ?>
    
    <?php else : ?>
         <!-- Stuff to do if there are no posts-->
    
    <?php endif; ?>

    but this is my output..
    post_count) > 1) : ?>

    what part of the code could I change so that I see a snippet of the latest blog entry? I was wnating this to be constantly changing as and when new content is uploaded.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have been reading a lot about this……

    I am getting conflicting information about using any wordpress content outside of wordpress’ loop.

    is it possible to have an excerpt of the latest post outside of wordpress on a static html page?

    I eventually found what I was looking for….

    to make wordpress posts show the excerpts outside of your wordpress directory you need to have a php file to do this.
    my file was called index.php within a separate directory.

    then I added this to the very start of the php file

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('/data01/abc/demo/resources/wordpress/wp-blog-header.php');
    //whatever your web directory structure is, http://www. did not work
    query_posts('showposts=1');
    ?>

    then had my html to keep the same layout and added this piece of code where i wanted the excerpt to be shown:

    <!-- mini loop for the excerpts -->
    <?php while (have_posts()): the_post(); ?>
      <h2><?php the_title(); ?></h2>
      <?php the_excerpt(); ?>
      <a href="<?php the_permalink(); ?>" class="text1">Read more...</a>
     <?php endwhile; ?>
    <!-- end the mini loop -->

    I hope this helps someone, as I had been hunting non stop for a few days, thinking it was the holy grail, now I think my next challenge will be, showing excerpts from other wordpress blogs not on my server, e.g. bbc blogs.

    This guy did it!!!

    Display WordPress content outside of your blog

    Worked for me on 2.6.2.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Mini Loop outside wordpress directory’ is closed to new replies.