Hueman Code Help!! Displaying Post by Category makes Sidebar disappear.
-
I am trying to get posts in specific categories to display on the patching pages. I have added the below code to the page.php template (I found on another support forum) which does give me my desired results. However, if there is content added to the page itself (page post not blog post), then the sidebars disappear.
I am a .php novice and am just learning. Can someone please advise me?
Here is the code I added to the page.php template:
<!– POST BY CATEGORY NAME –>
<?php
$page_name = $wp_query->post->post_name;
query_posts(‘category_name=’. $page_name);
?>
<?php while (have_posts()) : the_post(); ?>
<div class=”search-excerpt”>
<div class=”excerpt”><?php the_excerpt(); ?></div>
<p class=”permalink”>” rel=”bookmark” title=”Permalink to <?php the_title_attribute(); ?>”>Read more…</p>
</div>
<p class=”date”><?php the_time(‘l, F jS, Y’) ?></p>
<p class=”postmetadata”><?php the_tags(‘Tags: ‘, ‘, ‘, ”); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments ?’, ‘1 Comment ?’, ‘% Comments ?’); ?></p><?php endwhile; ?>
<!– END POST BY CATEGORY NAME –>
- The topic ‘Hueman Code Help!! Displaying Post by Category makes Sidebar disappear.’ is closed to new replies.