WordPress.org

Ready to get started?Download WordPress

Forums

Mini Loop outside wordpress directory (4 posts)

  1. ikthius
    Member
    Posted 5 years ago #

    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.

  2. ikthius
    Member
    Posted 5 years ago #

    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?

  3. ikthius
    Member
    Posted 5 years ago #

    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.

  4. sators
    Member
    Posted 5 years ago #

    This guy did it!!!

    Display WordPress content outside of your blog

    Worked for me on 2.6.2.

Topic Closed

This topic has been closed to new replies.

About this Topic