Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    189
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Wordpress Showing posts on homepage

    I've got a piece of code that was working fine on one site but now it's being all weird on another website. It takes the first 3 posts from my blog and posts a short summary of them, then a "read more" link.

    For some reason it is making the formatting of the first post different and not including the "read more" links. the text is there, but not the links.

    Here's the link and the code

    http://www.latitudesadventure.com/index-test.php (at the bottom of the page)

    PHP Code:
               <p align="left">
          <?php
    // Include WordPress 
    define('WP_USE_THEMES'false);
    require(
    './travel/wp-load.php');
    query_posts('showposts=3');
    ?>


    <?php
    /* site_last_updated
    *
    * This will check the modified_date of all published posts and give you the most recent date.
    *
    */
    function site_last_updated($d '') {
        
    $recent = new WP_Query("showposts=3&orderby=modified&post_status=publish");
        if ( 
    $recent->have_posts() ) {
            while ( 
    $recent->have_posts() ) {
                
    $recent->the_post();
                
    $last_update get_the_modified_date($d);
            }
            echo 
    $last_update;
        }
        else
            echo 
    'No posts.';
    }
    ?>
    <?php query_posts
    ('posts_per_page=3');?>
    <?php 
    while (have_posts()): the_post(); ?>
    <?php 
    endwhile; ?>
    <span class="title">The Latest News from Costa Rica</span><br/>
    <span class="subtours">Last Updated: <?php site_last_updated(''?></span><br/><br/>
    <span class="bodytext"><?php while (have_posts()): the_post(); ?></span>
    <span class="hoteltitle"><?php the_title(); ?></span>
    <span class="bodytext"><?php the_excerpt(); ?></span>
    <?php endwhile; ?>

          </p>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Try this instead ....

    PHP Code:


    <span class="title">The Latest News from Costa Rica</span><br/>
    <?php query_posts('posts_per_page=3');?>
    <?php 
    while (have_posts()): the_post(); ?>
    <span class="subtours">Last Updated: <?php site_last_updated(''?></span><br/><br/>
    <span class="hoteltitle"><?php the_title(); ?></span>
    <span class="bodytext"><?php the_excerpt(); ?></span>
    <?php endwhile; ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •