Frage

Hi there _ Must admit I'm scratching my head!

I've uploaded a demo site that uses a number of template pages. Everything works as expected, but whenever there's a page change the top 3 lines of the php template file are briefly displayed on the screen. I mean these lines:

/* 
Template Name: name
*/

You can see the display yourself at this URL : Demo website

If you click on any of the bottom 5 sub-items under 'PAINTINGS', the momentary display of the template name will appear top right of the screen

This has never happened to me before and I've tried everything that I can think of:

I'm not sure this fault is directly connected to php code. I think it might be more related to the Wordpress framework. But I will add one php template page, just in case! (The other templates are very much the same)

/* 
Template Name: Exhibition - Pilgrims 
*/
<?php get_header(); ?>
        
        <div class="container fadeIn perimeter">
            
            <section id="WhatWaterGaveMepage">

                <div class="row">
                    <div class="col-12">              
                        <div class="divPad">
                            <?php $featured_query = new WP_Query( array(
                                'category_name' => 'pilgrims-text'
                            )); ?>

                            <?php while($featured_query->have_posts()) : $featured_query->the_post(); ?>
                                <article class="fontBrand1 fontType1 pageText">
                                    <div class="horizBuffer2"></div>
                                    <p class="left"><?php the_content(); ?></p>
                                </article>
                            <?php endwhile; ?>
                       </div><!-- /.divPad -->
                    </div>
                </div><!-- /.row -->
             
            </section><!-- /#WhatWaterGaveMepage -->

            <section class="gallery" id="mainGallery">
                <div class="container">
                    
                    <div class="row">

                        <?php
                            global $query_string;
                            query_posts( $query_string . '&posts_per_page=-1' );
                        ?>
                        
                        <?php $featured_query = new WP_Query( array(
                            'category_name' => 'pilgrims'
                        )); ?>
                        
                        <?php while($featured_query->have_posts()) : 
                            $featured_query->the_post(); ?>
                                <div class="col-md-4">
                                    <div class="divPad">
                                        <a href="<?php echo the_permalink(); ?>">
                                            <?php $post_id = get_the_ID(); ?>
                                            <?php the_post_thumbnail(); ?>
                                        </a>
                                        <br />
                                        <span class="fontBrand1 fontType1 text"><?php echo the_title(); ?></span>
                                    </div><!-- /.divPad -->
                                </div>
                                
                                
                        <?php endwhile; ?>
                        <?php wp_reset_postdata(); ?>
                   
                    </div><!-- /.row -->
                </div><!-- /.container -->
            </section><!-- /#mainGallery -->
            
            <div class="horizBuffer2"></div>
        </div><!-- /.perimeter -->
        
<?php get_footer(); ?>

If anyone can help me get rid of this 'template name displayed' glitch I'll be very grateful _ Thanks

War es hilfreich?

Lösung

If your template file doesn't have the <?php tag at the top, you should add it.

<?php
/*
Template Name: Exhibition - Pilgrims 
*/

...is how the very top of your template file should look.

Your sample should read like this.

<?php
/* 
Template Name: Exhibition - Pilgrims 
*/
get_header(); ?>
        
        <div class="container fadeIn perimeter">
... [etc]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange
scroll top