Support » Themes and Templates » Custom template file

  • Let say I have a website on the address and I would like to create a file example.php in my custom created WP theme which contains simple loop to list all the posts:

    <?php query_posts('showposts=-1'); ?>
    <?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    			<h2><a>" rel="<?php the_ID(); ?>" 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;'); ?>
    			<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; ?>
    	<div class="navigation">
    		<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    		<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    <?php else : ?>
    	<h2 class="center">Not Found</h2>
    	<p class="center">Sorry, but you are looking for something that isn't here.</p>
    	<?php get_search_form(); ?>
    <?php endif; ?>

    Is it possible to make this file accessible as a WP page on the address without creating actual page?

    The purpose of this is that I would like to create WP theme which can handle this kind of pages right away after activation with no need to create new page with particular page template. Thank you in advance for any kind of help.

  • The topic ‘Custom template file’ is closed to new replies.