I'm new to template editing in wordpress and I'm trying to get a page description to show up on my site but it is not appearing. The URL I'm trying to get to display the description is here:


and I've attached the screenshot of the page description within wordpress. It appears to be using the archive template (why is it not using the page template?).

Here's the code for the archive template:

<?php get_header(); ?>
<div class="main">
    <!--<?php iinclude_page(17); ?>-->
        $category = get_the_category(); 
        $catName = $category[0]->cat_name;
        $catName = strtolower($catName);


    <?php if (have_posts()) : $first = true; ?>
        <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
        <?php /* If this is a category archive */ if (is_category()) { ?>
          <h1><?php single_cat_title(); ?></h1>
        <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
          <h1><?php single_tag_title(); ?></h1>
        <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
          <h1><?php echo get_the_time('F jS, Y'); ?></h1>
        <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
          <h1><?php echo get_the_time('F, Y'); ?></h1>
        <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
          <h1><?php echo get_the_time('Y'); ?></h1>
        <?php /* If this is an author archive */ } elseif (is_author()) { ?>
          <h1><?php _e( 'Author Archive', 'gray_white_black' ); ?></h1>
        <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
          <h1><?php _e( 'Blog Archives', 'gray_white_black' ); ?></h1>
        <?php } ?>

        switch ($catName)
            case "east side":
            case "downtown":
            case "mid-city":
            case "west side":
            case "coastal":
            case "valley":

        <ul class="post-list">
        <?php while (have_posts()) : the_post();
            if($first) $class = "first-in-row";
            else $class="";
            $first = !$first;
            <!-- Start: Post -->
            <li <?php post_class($class); ?>>
                <?php the_post_thumbnail(); ?>
                <p class="categories"><?php the_category(", "); ?></p>
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php edit_post_link(__('Edit', 'gray_white_black'), '', ''); ?></h2>

                <?php the_excerpt(); ?>
                <p class="more"><a href="<?php the_permalink() ?>"><?php _e( '&raquo;&raquo; ', 'gray_white_black' );?></a></p>
                <?php if(has_tag()): ?><p class="tags"><span><?php the_tags(""); ?></span></p><?php endif; ?>
            <!-- End: Post -->
        <?php endwhile; ?>

        <p class="pagination">
            <span class="prev"><?php next_posts_link(__('&laquo; Previous Posts', 'gray_white_black')) ?></span>
            <span class="next"><?php previous_posts_link(__('Next posts &raquo;', 'gray_white_black')) ?></span>

    <?php else : ?>
        <h2><?php _e( 'Not found', 'gray_white_black' ); ?></h2>
        <p><?php _e( 'Sorry, but you are looking for something that isn\'t here.', 'gray_white_black' ); ?></p>
        <?php get_search_form(); ?>
    <?php endif; ?>
<?php get_sidebar(); ?>

<?php get_footer(); ?>

Where, in the code above, the_post(), appropriately, refers to the content for the home listing within the category displayed on the page. But how do I get the_post() for the page itself, shown in the screenshot? Thanks.

enter image description here

  • Can we see the entire template file code, please? Also, just to clarify: this file is archive.php, right? Commented May 24, 2012 at 13:30
  • Related: I can't see the screenshot; can you describe what content you want to output/display in archive.php? Commented May 24, 2012 at 13:35
  • @Chip - Updated the post to include the full template code, including my hardcoded work around for the issue
    – mheavers
    Commented May 24, 2012 at 14:26
  • @Chip - I want to output page content on a category template, where the category name is equal to the page name. I've used other CMS platforms, such as expression engine, where you can just pull URL segment variables - so you could say if url segment 1 == "east_side" - display page_content for page "east_side" - but I'm not familiar with how to do this for wordpress.
    – mheavers
    Commented May 24, 2012 at 14:29

2 Answers 2


But how do I get the_post() for the page itself...?

Short answer: you don't.

The archive.php file is part of the WordPress Template Hierarchy, and is simply a template file. It has no post content of its own. It simply loops through and outputs the content of the posts that match the current query.

If you want to output a specific description, you'll need to edit the archive.php file directly, to tell it what you want to output.


I want to output page content on a category template, where the category name is equal to the page name.

You can do this, but it's certainly not anything that's inherent with WordPress. Static Pages and blog posts are two entirely different types of content (i.e. two completely different post-types), and there is no correlation between the two. WordPress simply doesn't associate blog posts that have a certain category taxonomy term with a static page that has the same slug as that taxonomy term.

That said, you can associate the two. The process is a bit fragile, though.

if ( is_category() ) {
    // Get current category slug
    $cat = get_query_var( 'cat' );
    $cat_object = get_category( $cat );
    $category_slug = $cat_object->slug;

    // Get the ID of the static page with the same slub
    $category_static_page_id = get_page_by_path( $category_slug );

    // If such a page exists, get it
    if ( isset( $category_static_page_id ) ) {
        // Get the static page object
        $category_static_page = get_page( $category_static_page_id );

        // Output page content
        // Apply the usual the_content filters,
        // for usual "nice" formatting
        echo apply_filters( 'the_content', $category_static_page->post_content );
  • Yeah - figured that one out. It was a little confusing due to the way the theme I selected was using templates. The template it has selected is "archive.php" but that template outputs categories. Maybe it should be using a category template instead, I don't know. You can see the revised code to see my current workaround
    – mheavers
    Commented May 24, 2012 at 14:31
  • See updated answer, that shows an example of a more dynamic implementation. Note: you probably should use category.php for category-specific output like this. If you do, you can omit the if ( is_category() ) conditional. Commented May 24, 2012 at 15:01

If you know the page ID, the simplest answer would be to get the content for the page.

// This retrieves the content from the post or page where ID = $page_id.
// You can either set this above here, or call get_the_content(12). Your choice.
$parent_page_content = get_the_content($page_id)

// Clean it up and make it a bit more legible:
$parent_page_content = str_replace(']]>', ']]&gt;', $parent_page_content);
$parent_page_content = apply_filters('the_content', $parent_page_content);

// Now echo out the content in place! <p> tags won't be necessary here, btw.
echo $parent_page_content;

This method doesn't interfere with the loop at all, so you won't need to use wp_reset_query() after doing this. Also, because you're applying the the_content filter to your text, it'll automatically add the paragraph and break line tags for you.

Hope this helps.

  • Definitely does - I actually did this with the help of a plugin, but I was hoping for a more dynamic way to do it. I installed a plugin called "Improved Include Page" which allows you to output a page's content in any template using its ID. So I wrote a switch statement saying switch ($catName) { case "east side": iinclude_page(17); break; I'd like to find a dynamic way to do this though, as there are multiple categories for which I need to add multiple page content.
    – mheavers
    Commented May 24, 2012 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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