• i have problem with this code , everything is good in this code but in a website i get this :
    Fatal error: Uncaught Error: Call to a member function have_posts() on null in C:\xampp\htdocs\swinew\wp-content\themes\mywptheme\index.php:13 Stack trace: #0 C:\xampp\htdocs\swinew\wp-includes\template-loader.php(106): include() #1 C:\xampp\htdocs\swinew\wp-blog-header.php(19): require_once(‘C:\\xampp\\htdocs…’) #2 C:\xampp\htdocs\swinew\index.php(17): require(‘C:\\xampp\\htdocs…’) #3 {main} thrown in C:\xampp\htdocs\swinew\wp-content\themes\mywptheme\index.php on line 13

    the code in index.php is

    <?php get_header();?>

    <?php

    $args = array(
    ‘post_type’ => ‘post’,
    ‘posts_per_page’ => 3,
    );

    $blogpost = new WP_query($args);

    while($blogposts->have_posts()) {
    $blogposts->the_post();
    ?>

    “>
    <h3><?php the_title(); ?></h3>

    <?php the_excerpt();?>

    <?php

    }

    ?>
    <?php get_footer(); ?>

    please tell me what wrong , i did everything right

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Uncaught Error: Call to a member function have_posts()’ is closed to new replies.