• I have inserted the following code to my homepage

    <?php $my_query = new WP_Query('category_name=beauty-tips&showposts=2'); ?>
    
     <?php while ($my_query->have_posts()) : $my_query->the_post();?>
    
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
      <?php endwhile; ?>

    to try and get the latest 2 post in a certain category to show there.

    At the moment the only thing that shows up is

    have_posts()) : $temp_query->the_post();?>

    For some reason it is displaying everything that is typed after $my_query
    I’m pretty new to PHP and WordPress and I can’t work out what could be wrong.

    The code was copied directly from an article on this website

    Thanks in advance

    Webecho

  • The topic ‘$my_query->have_posts()) problems’ is closed to new replies.