• Resolved Nick5a1

    (@nick5a1)


    Hi all,

    I currently use archive.php to show a list of all trials within the particular category. I want to on a separate page have a list of all posts (across all categories) listed by chronological order, but using the same formatting as my archive.php.

    So I copied the contents of my archive.php into a new page template, and made a page that used that template, but when I view the page it is empty/no posts. Can anyone tell me what I’m doing wrong.

    Here is my archive.php/new template code:

    <?php
    /*
    Template Name: AllPosts
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="page-main">
    	<div class="page-main-holder">
    	<div id="page-content" style = "padding: 11px 0 30px 0; width: 950px;">
    	<?php if (have_posts()): ?>
    
    		<div class="post">
    			<?php $post = $posts[0]; ?>
    			<h1 class="archive_title">
    				<?php if (is_category()): ?>
    					Clinical Trials in <?php single_cat_title(); ?>
    				<?php elseif (is_day()): ?>
    					Archive for <?php the_time('F jS, Y'); ?>
    				<?php elseif (is_month()): ?>
    					Archive for <?php the_time('F, Y'); ?>
    				<?php elseif (is_year()): ?>
    					Archive for <?php the_time('Y'); ?>
    				<?php elseif (is_author()): ?>
    					Author Archive
    				<?php elseif (isset($_GET['paged']) && !empty($_GET['paged'])): ?>
    					Blog Archives
    				<?php endif; ?>
    			</h1>
    		</div>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<div class="main-holder-archive">
    			<div id="post-<?php the_ID(); ?>">
    				<div id = "archive_title_back">
    					<h2 class="archive_h2"><a>" rel="bookmark" title="View <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                    </div>
    				<div id = "archive_info">
    					<p class = "location"><strong>Location:</strong> <? $category = get_the_category(); echo $category[1]->cat_name; ?></p>
    					<p class = "condition_2"><strong>Condition:</strong> <?php the_tags('',', '); ?></p>
    					<a>" rel="bookmark" title="View <?php the_title_attribute(); ?>"></a>
    				</div>
    			</div>
    		</div>
    		<?php endwhile; ?>
    
    	    <h2 class="archive_title_empty">Trialfacts has just launched! If you like we can <a href="https://trialfacts.com/new-trials-mailing-list/">send you an email</a> when we have new trials in <?php single_cat_title(); ?> that you might be interested in.</h2>
    		<div class="navigation">
    			<div class="alignleft"><?php previous_posts_link('? Previous Entries') ?></div>
    			<div class="alignright"><?php next_posts_link('Next Entries ?') ?></div>
    		</div>
    
    	<?php else: ?>
    
    		<div class="post">
    			<h2 class="archive_title_empty">Sorry! We currently have no trials listed for <?php single_cat_title(); ?>.</h2><h2 class="archive_title_empty">Trialfacts is brand new. If you like we can <a href="https://trialfacts.com/new-trials-mailing-list/">send you an email</a> when we have trials in <?php single_cat_title(); ?> that you might be interested in.</h2>
    		</div>
    
    	<?php endif; ?>
    
    </div>
    </div>
    </div>
    <div class="clearfooter"></div>
    </div> <!-- end wrapper -->
    
    <?php get_footer(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use archive.php to show all posts’ is closed to new replies.