Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm very new to WordPress, but I'm currently doing work on a site built on the platform. I'm making my way through, but I've run into a bit of a problem.

I'm trying to add content from the text editor of the site's blog page, which uses the standard index.php template. However, when I use <?php the_content(); ?> like other pages use, it returns the content of the latest post. Is there a way to get the content from the page editor instead?

I've been looking all morning without really finding anything satisfactory. Any advice would be greatly appreciated!

            <section id="primary" >
                <?php the_content(); ?>
                <div class="content" role="main" data-target="index" >

                    <?php if (have_posts()) : ?>

                        <?php get_template_part('inc/loop', get_post_type() ); ?>

                    <?php else : ?>

                        <?php get_template_part('inc/content', 'none' ); ?>

                    <?php endif; ?>

                </div><!-- end content -->
            </section><!-- end primary -->
share|improve this question
1  
This WordPress Codex is invaluable to all WordPress'ers new and old. –  eyoung100 Jun 3 at 16:48

2 Answers 2

up vote 0 down vote accepted

When you configure your blog (posts) page under Settings > Reading, that page becomes nothing more than a placeholder - in other words, you won't be able to grab it's title/content within index.php without a little trickery:

if ( $page_id = get_option( 'page_for_posts' ) ) {
    echo get_the_title( $page_id );

    // the_content() doesn't accept a post ID parameter
    if ( $post = get_post( $page_id ) ) {
        setup_postdata( $post ); //  "posts" page is now current post for most template tags        
        the_content();
        wp_reset_postdata(); // So everything below functions as normal
    }
}
share|improve this answer
    
Worked fantastically, thank you! –  Brecon Jun 3 at 18:24

I think you want to set a page as the home page rather than a post. You can set this using wordpress settings. You have to set a selected page that will display on the site's home.

  • Login to admin end and go to Settings -> Reading
  • Select the 2nd option (A static page) for the setting Front page displays
  • Then select the page from the dropdown list for Front page whichever you want to set as the home page.
  • Save the settings.

Now if you check your site, you should see a page rather than post.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.