• alecjacobryan

    (@alecjacobryan)


    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 –>

Viewing 1 replies (of 1 total)
  • Thread Starter alecjacobryan

    (@alecjacobryan)

    Additional –

    Even bracketing the script with <!– –> to disable it does not bring the sidebars back. It does keep he posts from displaying but still interferes with the sidebars coming back. I find that really weird because I thought those brackets make the code “invisible” to the server. I have to completely delete the code to get the page to display the sidebars again.

    If there is no content posted on the page itself then the code works fine and sidebars appear.

Viewing 1 replies (of 1 total)
  • The topic ‘Hueman Code Help!! Displaying Post by Category makes Sidebar disappear.’ is closed to new replies.