The MU forums have moved to WordPress.org

Site not using Template (9 posts)

  1. displaced2000
    Member
    Posted 18 years ago #

    Ok,

    I have my site setup cuurrently with a home.php which reads in a header.php and a footer.php

    All quite standard.

    I dont have any page.php or index.php as all my pages are going to be coded quite different.

    so I have a link on my home page for gallery which is hard coded into the home.php file
    <li><a href="<?php bloginfo('url'); ?>/gallery" class="active">gallery </a></li>

    and i've set up a page called gallery in the backend of wordpress.

    I now have a gallery.php file which has the content of the gallery page on.

    now according to the template hierarchy it should look for pagename.php first so in this case gallery.php which i have got. but its just displaying a blank screen which i understand is because i have no other pages for it to display i.e. page.php or index.php...

    my question is why is it not picking up the gallery.php in the first place and showing the content...

    Cheers

  2. lunabyte
    Member
    Posted 18 years ago #

    AFAIK, you have to specify gallery.php as the template file when you created the page which sets the "gallery" permalink.

  3. displaced2000
    Member
    Posted 18 years ago #

    I dont think that is actually true.

    according to this page in the codex
    http://codex.wordpress.org/Template_Hierarchy

    it first looks for the php file with the same name as the page being called in my case gallery.php, then if not found will use page.php and then finally index.php

    and in the case of my page neither of those are available so it displays nothing.

  4. andrea_r
    Moderator
    Posted 18 years ago #

    Stick a name at the top of the gallery page template. That's what they mean by "name" in this case.

    /*

    Template name: gallery

    */

    Then edit the gallery page and choose "gallery" as the page template.

    And if that doesn't work, then your php code in gallery.php has an error.

    White screen = errors.

  5. displaced2000
    Member
    Posted 18 years ago #

    Ok so i put the above template name at the top of my gallery.php as described above.

    But i dont get the option to select this as a page template under manage pages.

    I've had this problem before and couldn't resolve it. Thats why i changed to using the default hierarchy descibed in the above link.

    I am confident that i dont have any errors in my code. because i have had this page working previously.

    here is my code so far

    /*
    
    Template name: gallery
    
    */
    
    <?php get_header(); ?>
    
      <div id="main-nav">
    
                <li><a href="<?php bloginfo('url'); ?>/">home </a></li>|
                <li><a href="<?php bloginfo('url'); ?>/our-services">our services </a></li>|
                <li><a href="<?php bloginfo('url'); ?>/gallery" class="active">gallery </a></li>|
                <li><a href="<?php bloginfo('url'); ?>/training">training </a></li>|
                <li><a href="<?php bloginfo('url'); ?>/solutions">solutions </a></li>|
        		<li><a href="<?php bloginfo('url'); ?>/contact">contact</a></li>
    
      </div>
    
          <div id="sidebar-left_archive">
    
                    <div class="headers">
                      Gallery
                    </div> 
    
                     <div id="cat_buffer">
    
    					 <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&hide_empty=0&exclude=1, 5, 6, 7, 8'); ?>
                         <p>
                    <div class="headers2">
                          Tags
                          </div>
    
                          <?php wp_tag_cloud('smallest=10&largest=10&number=30&orderby=count&format=list'); ?>
    
            		</div> 
    
          </div>
    
          <div id="content_archive">
    
           					<?php
    						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    						query_posts("cat=8&showposts=4&paged=$paged");?>
                            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                            <div class="entry <?php if(is_home() && $post==$posts[0] && !is_paged()) echo ' firstpost';?>">
                        	<!--<div class="date"><p><span class="month"><?php the_time('M') ?></span><span class="day"> <?php the_time('j') ?> </span></p></div>-->
                        	<h3 class="etitle" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark">
                            <?php the_title(); ?>
                            </a> </h3>
                            <div class="emeta">
                            <?php //the_time('F dS, Y');
                            echo "  Category: ";the_category(' | ');?>
                            </div>
                            <div class="ebody">
                            <?php the_content();?>
                            </div>
                            <?php trackback_rdf(); ?>
                            </div>
                            <?php comments_template(); // Get wp-comments.php template ?>
                            <?php endwhile; else: ?>
                            <p>
                            <?php _e('Sorry, no posts matched your criteria.'); ?>
                            </p>
                            <?php endif; ?>
                            <p>
                            <?php posts_nav_link(' — ', __('&laquo; Older Work'), __('Newer Work &raquo;')); ?>
                            </p>
    
        </div>     
    
          <div id="footer">
                <div class="testimonials">
                	<?php
                	global $customFields;
    				$customFields = "'testimonial'";
                    $customPosts = new WP_Query();
                    add_filter('posts_join', 'get_custom_field_posts_join');
                    add_filter('posts_groupby', 'get_custom_field_posts_group');
                    $customPosts->query('showposts=1&orderby=rand' );//Uses same parameters as query_posts
                    remove_filter('posts_join', 'get_custom_field_posts_join');
                    remove_filter('posts_groupby', 'get_custom_field_posts_group');
                    while ($customPosts->have_posts()) : $customPosts->the_post();
                    $testimonial = get_post_custom_values("testimonial");
    				?>
    				<li><a href="<?php the_permalink() ?>" class="test1"><?php echo $testimonial[0]; ?></a></li>
                    <?php endwhile; ?>
                    <li><img src="/Client1953/wp-content/themes/T2_main_theme/images/autodesk.png" /></li>
                <?php
                	global $customFields;
    				$customFields = "'testimonial'";
                    $customPosts = new WP_Query();
                    add_filter('posts_join', 'get_custom_field_posts_join');
                    add_filter('posts_groupby', 'get_custom_field_posts_group');
                    $customPosts->query('showposts=1&orderby=rand' );//Uses same parameters as query_posts
                    remove_filter('posts_join', 'get_custom_field_posts_join');
                    remove_filter('posts_groupby', 'get_custom_field_posts_group');
                    while ($customPosts->have_posts()) : $customPosts->the_post();
                    $testimonial = get_post_custom_values("testimonial");
    				?>
    				<li><a href="<?php the_permalink() ?>" class="test1"><?php echo $testimonial[0]; ?></a></li>
                    <?php endwhile; ?>
                </div>
    
                <div class="icons">
    				<li><a href="/news" class="news">News</a></li>
                    <li><a href="/autotrain" class="autotrain">autotrain</a></li>
                    <li><a href="" class="forum">forum</a></li>
                    <li><a href="" class="tutorials">tutorials</a></li>
                    <li><a href="" class="blog">blog</a></li>
                </div>
          </div>
    
    </div>
    
    <?php get_footer(); ?>
  6. andrea_r
    Moderator
    Posted 18 years ago #

    The top part is incorrect. Shoudl be
    <?php

    /*

    Template name: gallery

    */

    get_header(); ?>

    Comments need to go inside the code.

  7. displaced2000
    Member
    Posted 18 years ago #

    oh i was so excited that i made a simple mistake and this would fix the problem.

    but it still doesnt show up as a page template under manage pages.

    is this function usually this awkward. I've never experienced this before.

  8. andrea_r
    Moderator
    Posted 18 years ago #

    nope, it's not usually this hard. Something's messed up somewhere.

    I haven't had the chance to test your page template.

  9. MrBrian
    Member
    Posted 18 years ago #

    <?php
    /*
    Template Name: Gallery
    */
    ?>

    Try that exactly, and if it doesnt work, use pastebin.com to paste your entire file and i'll tell you what's wrong.

About this Topic

  • Started 18 years ago by displaced2000
  • Latest reply from MrBrian