Support » How-To and Troubleshooting » [Resolved] How Display Content on a Custom Page

[Resolved] How Display Content on a Custom Page

  • I am using wordpress as a CMS. I have created a custom page template to have a page specific side bar. The only problem I am encountering is that I cannot find how to display the content from the actual ‘wordpress page publishing tool’.

    Here is what the custom page code looks like:

    Template Name: Day Tips
    <?php get_header(); ?>
    <?php include (TEMPLATEPATH . '/sbdaytrips.php'); ?>
    <?php the_content(); ?>
    <?php get_footer(); ?>

    I assumed that <?php the_content(); ?> would fetch the content that I create in the wordpress dashboard, but it does anything.

    Any ideas?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You forgot to create “theloop” for the page template.

    If I remember correctly, the_content() only works inside the loop.

    the_content would work…..with the rest of the loop


    you gotta tell WP to load posts at very least…… some kind of query

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>


    hmm thanks for the heads up.
    Is there a way to start a look without looking for posts?
    There are not any posts on this website… and without posts it just continues to look for them.

    I tried running and if loop with no success:( The if loop executes, but it doesn’t load the content still…

    <?php get_header();?>
    <?php include (TEMPLATEPATH . '/sbdaytrips.php');?>
      <?php if(have_posts()) :?>
        <div class="post">
            <div class="entry">
                    <?php the_content(); ?>
    <?php endif; ?>
    <?php get_footer(); ?>

    It seems kinda sloppy to have to run an if loop just to do this, does anyone else have a better idea?

    the best bet would be to model the template after page.php

    you still have an incomplete loop…..

    <?php if(have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    but if you are just trying to have a special page specific sidebar show up on a certain page, I believe you could just edit your page.php with a conditional statement to load the special sidebar for a specific page.


    <?php get_header(); ?>
    <?php include (TEMPLATEPATH . ‘/sbdaytrips.php’); ?>

    <?php //loop to get content
    if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    <?php the_content(); ?>

    <?php endwhile(); ?>

    <?php get_footer(); ?>

    That said, you can create a custom field with text content to display IF it exists in or outside of the loop.

    For example, using c2c’s excellent get custom plugin, you can add a custom field to the desired page (let’s call the key “default-text”) and call that from your custom page template outside of the loop with the plugin’s c2c_get_recent_custom(‘default-text’); function. But of course, that means the text will display for every page that uses your custom template, which is great if you have a common element for all pages.

    Within the loop however, you can call SPECIFIC text (default-text) for the current page only IF the custom field ‘default-text’ exists for that page using c2c_get_custom(‘default-text’);

    It will only display the specific text WHEN and IF that field exists for THAT page.

    You can read about the plugin here:

    Get Custom Field Values

    It’s the one of my MUST-USE plugins for every site done as a CMS

    Thanks alot!


    few corrections to your code, there is also a simpler way to write it:

    <?php get_header(); ?>
    <?php include (TEMPLATEPATH . '/sbdaytrips.php'); ?>
    //begin loop
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    <?php get_footer(); ?>
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] How Display Content on a Custom Page’ is closed to new replies.