WordPress.org

Ready to get started?Download WordPress

Forums

New Template for showing content and posts - sidebar not detecting ID and parent (1 post)

  1. csbecker
    Member
    Posted 2 years ago #

    I've created a custom template for showing content and a listing of posts on a page within a category. Everything works fine except that the sidebar isn't detecting the Page ID or its parent Page ID.

    Here's the link to the page that is not correctly showing conditional text in the right sidebar (this is the parent): blend-my-learning-test

    Here's a link to a page that is correctly showing the conditional text in the right sidebar (this is a child but I've assigned the default template to show that the conditional code in the right sidebar actually works): blend-my-learning-school-1

    (note: these links won't work at a later time when I have the problem solved!)

    Here's the code for the non-working page:

    <?php /* Template Name: Page Blend My Learning Blog */ ?>
    <?php get_header(); ?>
    <div id="page_content">
    <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
      <div class="post" id="post-<?php the_ID(); ?>">
            <h2><?php the_title(); ?></h2>
    	<div class="entry">
    	<?php the_content(); ?>
            <hr />
    <?php endwhile; ?>
      <?php query_posts('cat=92&orderby=date&order=ASC&posts_per_page=5'); //retrieves category publications posts         ?>
      <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
            <strong><p id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></p></strong>
            <small><?php the_time('F jS, Y') ?> by
    <?php //foreach((get_the_category()) as $category) { echo $category->cat_name . ' | '; } ?>
    <?php $category = get_the_category(); echo $category[1]->cat_name; ?>
    	</small><br />
            <?php the_excerpt() ?>
            <hr />
     <?php endwhile; ?>
     <?php endif; ?>
    <!-- end of listing -->
    
    <div class="comments-template"><?php comments_template(); ?></div>
    </div><!-- end entry -->
      <div class="spacer_main_content"></div>
    </div><!-- end post -->
    <?php edit_post_link('Administrator or Editor - Edit this page now...>', '<p>', '</p>'); ?>
    <?php else : ?>
    <div class="post">
    	<h2><?php _e('Not Found'); ?></h2>
    	<div class="entry">
    <p class="notfound"><?php _e('Sorry, but you are looking for something that isn't here.'); ?></p>
    	</div>
    <div class="spacer_main_content"></div>
    </div>
    <?php endif; ?>
    </div><!-- end page content -->
    <?php get_footer(); ?>

    Here's the code for the right sidebar (only the important code):

    <?php if ( is_page(3962) || '3962' == $post->post_parent ) : ?>
        <p>Here's a new section</p>
    <?php endif; ?>

    I'm not sure what I'm missing, but I'm guessing that I have something wrong in my template page code since with the default template, we're seeing the conditional text show up.

    Any help would be greatly appreciated!
    Thanks! Chris

Topic Closed

This topic has been closed to new replies.

About this Topic