WordPress.org

Ready to get started?Download WordPress

Forums

the_content() ? (5 posts)

  1. rich2013
    Member
    Posted 1 year ago #

    I saved a new template as follows:

    <?php
    /*
    Template Name: splash-page
    */
    ?>
    <?php get_header(); ?>
    <div id="container">
    	<div id="content">
    		<?php the_content(); ?>
    	</div><!-- #content -->
    </div><!-- #container -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum's parser.]

    When I Add New Page and enter some content, the content does not show up when I View Page. Is 'the_content()' responsible for displaying content and if yes why isn't it working?

    Rich

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    There's no Loop on that page template.

  3. rich2013
    Member
    Posted 1 year ago #

    I only want to output the content of the page, not the posts (outputting the posts would require a loop but not the content?)

  4. rich2013
    Member
    Posted 1 year ago #

    Found the solution:

    <?php

    $page_data = get_page( $page_id );
    echo $page_data->post_content;

    ?>

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    fyi, the loop is also used when showing just the content of a page;

    minimum example of a loop for a page template:

    <?php the_post(); the_content(); ?>

    your example would for instance not render any shortcode that might be in the page;

    do at least:

    echo apply_filters('the_content',$page_data->post_content);

Topic Closed

This topic has been closed to new replies.

About this Topic