Forums

post news code into page? (2 posts)

  1. pmmarketing
    Member
    Posted 2 weeks ago #

    hello, i'm trying to show 3 news storys using wordpress php code on the front page of my website.

    I've pasted this into a page I've called home

    <?php
    					query_posts( 'showposts=3' );
    					if (have_posts()) :
    						while (have_posts()) : the_post();
    
    				?>
    
    						<h3 class="post-title left"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    
    								<?php the_content(''); ?> 
    
    								<a href="<?php the_permalink() ?>#more-<?php the_ID(); ?>" rel="bookmark" title="Continue Reading <?php the_title_attribute(); ?>">Continue Reading</a>
    
    				<?php
    						endwhile;
    					endif;
    				?>

    It shows 3 storys, but also includes a 4th which I can't work out how to get rid of it?

    you can view the example at http://www.boxberrie.co.uk/

  2. MichaelH
    moderator
    Posted 2 weeks ago #

    <?php
     $args=array(
       'showposts'=>3,
       'caller_get_posts'=>1
     );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php the_content(''); ?>
    <?php
    endwhile;
    }
    ?>

Reply

You must log in to post.

About this Topic