• Hi Admin,

    I’m creating a custom page with a custom query and here the code i found on the codex.www.ads-software.com “$page = new WP_Query( ‘pagename=home’);” my problem i can’t pull the content of the page i don’t know how please help me.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ricarjay

    (@ricarjay)

    Hi Esmi,

    Thank for you reply I already did check the link, i did also tried copy some of the code and here what i got

    <?php $page = new WP_Query( 'pagename=home'); while( $page->have_posts() ) : $page->the_post(); ?>
        <div class="container2 clearfix">
          <?php  the_content();  ?>
        </div><!--container2--><?php endwhile; ?>

    it did show the content that i need, but sadly i also got this error message
    “Fatal error: Call to a member function have_posts() on a non-object in C:\xampp\htdocs\webfast\wp-content\themes\webfast\chome.php on line 28”

    what do you think i did wrong ? thanks for your help

    Have you checked that your Home page actually has the slug “home”?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom loop’ is closed to new replies.