• On my blog @ https://www.atriskstoriesofhope.com/wordpress/podcast (which is a wordpress page) I got the posts from the podcast category to display via the small snippet of code below. It displays the posts fine, but without any of the stuff that normally comes along with posts (being able to click the post title to see a single via, checking comments, etc.). What code do I need to use to have the posts from category 3 (podcast category) to display like posts normally do on https://www.atriskstoriesofhope.com/wordpress

    Here is the code below…and below that is the code snippet above the loop.

    Thanks

    Antonio

    <?php
       if (is_page(23) ) {
          query_posts("cat=3");
       }
    <?php
       if (is_page(23) ) {
          query_posts("cat=3");
       }
    
    ?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The post content and metadata is generated inside the loop, which is present here:

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

    If your posts already appear the way you like on your blog’s home page, I suggest looking at the chunk of the template that generates that. This will depend on your theme, but will probably be in home.php or index.php. Find the loop in that template file, copy it, and paste it in here.

    Thread Starter antoniop

    (@antoniop)

    NOTE: I replaced the loop in page.php with the loop from index.php. Now it shows all of the comments, etc. and all of the formatting on the posts just like in the homepage. The only problem is when I try to click on one of the post titles, I get a blank page.

    https://www.atriskstoriesofhope.com/wordpress/what-is-the-number-one-question-in-education

    If I log into admin>manager>edit post>view post, I still get a blank page.

    This is the two bits of code. The first one is from index.php and the second one is from page.php I’m kind of at a loss right here. Is it possible that I can take all of the code of the loop from index.php and replace the loop in page.php. I’m sure I will have to add some more code to only display the posts from my podcast category.

    Thanks

    <?php
       if (is_page(23) ) {
          query_posts("cat=3");
       }
    
    ?>
                    	</small>
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    
    				<?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    <?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    <!--                    <?php if(function_exists("wjt_diggThisPost" )) wjt_diggThisPost();?>-->
    				<img src="../images/feed.png" />Subscribe via RSS &nbsp;<img src="../images/email.png" />Subscribe via Email &nbsp;
    <!-- ADDTHIS BUTTON BEGIN -->
    <script type="text/javascript">
    addthis_pub             = 'antoniop';
    addthis_logo            = 'https://www.addthis.com/images/yourlogo.png';
    addthis_logo_background = 'EFEFFF';
    addthis_logo_color      = '666699';
    addthis_brand           = 'www.atriskstoriesofhope.com';
    addthis_options         = 'favorites, email, digg, delicious, myspace, facebook, google, live, more';
    </script>
    <a href="https://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="https://s9.addthis.com/button1-share.gif" width="125" height="16" border="0" alt="" /></a>
    <script type="text/javascript" src="https://s7.addthis.com/js/152/addthis_widget.js"></script>
    <!-- ADDTHIS BUTTON END -->
                                      <?php if(function_exists('wp_email')) { email_link(); } ?>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php if(function_exists('wp_print')) { print_link(); } ?>  &nbsp;&nbsp;<img src="../images/comments.png" /><?php the_tags('Tags: ', ', ', ''); ?><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?><?php edit_post_link('Edit', '', '  '); ?>
    <hr size = 5/>
    			</div>
    
    		<?php endwhile; ?>
    Thread Starter antoniop

    (@antoniop)

    I was going about this all the wrong way. Alls I had to do was to save index.php as category3.php. Then when I loaded https://www.atriskstoriesofhope.com/category/podcast I got my category page with all of the podcasts post.

    lesson to all, search for answers…it helps ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Putting posts on a page…above the loop…missing comments, etc.’ is closed to new replies.