WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add content of a "Pages" page to a div in my template (5 posts)

  1. drumnation
    Member
    Posted 3 years ago #

    Hi I'm new to WordPress and still finding my way around. I've created a html mockup of the illustrator site in divs with css and now I want to add the content dynamically.

    First off I chose to put the positioning statement text in a "pages" page rather than a post. I've been reading through the docs and can't seem to find the template tag I'm looking for. Any help would be much appreciated.

    -Dave

  2. s_ha_dum
    Member
    Posted 3 years ago #

    Dave,

    I don't think I know what you are talking about. Based on your description, I am very confused.

  3. CounterDax
    Member
    Posted 3 years ago #

    So, I believe you want to grab the content of a page and output it in a certain location? This is possible by creating a new WP-Query class, but this does mean you're making an extra database request, so use sparingly.

    <?php
    // Create second WordPress loop
    $page_content = new WP_Query( 'pagename=page-slug' );
    
    while( $page_content->have_posts() ) : $page_content->the_post();
    	// Your content output goes here
    	echo '<h2>';
    	the_title();
    	echo '</h2>';
    	the_content();
    endwhile;
    
    // Don't forget to reset the post data!
    wp_reset_postdata();
    ?>

    Also see the codex entry of WP_Query

  4. drumnation
    Member
    Posted 3 years ago #

    Worked perfectly. Thank you.

  5. drumnation
    Member
    Posted 3 years ago #

    Where it says new WP_Query( 'pagename=page-slug' );
    I put WP_Query( 'page_id=8' );

    That's all I needed to call up a particular page. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic