为什么我的&#39; functions.php&#39;页面工作,直到我包括&#39; <! - ?php'? - >

时间:2015-01-12 19:56:11

标签: wordpress function

我刚刚开始构建我的第一个Wordpress主题,并且遇到一个问题,即功能(限制字符)不起作用。我可以通过不在函数页面上包含开始的php标记来使函数工作,但随后函数代码出现在索引上。这是索引代码:

<?php get_header(); ?>
          <div class="pageImg">
          <img src="images/Cara&amp;Jay_02.gif" alt="Verbs &amp; Pixels" /> 
          </div>

            
            <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
            
            
            
            <div class="blog"> 
                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a> 
                <h1><?php the_title(); ?></h1>
                <p><?php the_excerpt(); ?></p>
            </div>
            <?php endwhile; ?>
            
            <?php else : ?>
            <h1>nothing found bro.</h1>
            <?php endif; ?> 
            
            <h1>Contributors</h1>
            <div class="con">
                <img src="images/Cara&amp;Jay_28.gif" alt="Jay Cowle" />
                <h1>Jay Cowle</h1>
                <p>Lorem ipsum dolor sit amet, 
                consectetur adipisicing elit, 
                sed do eiusmod tempor incididunt 
                ut labore et dolore magna aliq. 
                Ut enim ad minim veniam.</p> 
            </div>
            <div class="con">
                <img src="images/Cara&amp;Jay_30_30.gif" alt="Cara Fielder" />
                <h1>Cara Fielder</h1>
                <p>Lorem ipsum dolor sit amet, 
                consectetur adipisicing elit, 
                sed do eiusmod tempor incididunt 
                ut labore et dolore magna aliq. 
                Ut enim ad minim veniam.</p>
            </div>
            <div class="ad"><img src="images/Cara&amp;Jay_25.gif" alt="Advert" /></div>   
        </div>          	
	</div>
<?php get_footer(); ?>

继承函数页面代码:

<?php
/**
 * VerbsPixelsTheme functions and definitions
 *
 * @package VerbsPixelsTheme
 * @since VerbsPixelsTheme 1.0
 */

function new_excerpt_length($length) {
	return 300;
}
function excerpt_ellipse($text) {
   return str_replace('[...]', ' <a href="'.get_permalink().'">Read More</a>', $text);
}
add_filter('the_excerpt', 'excerpt_ellipse');
add_filter('excerpt_length', 'new_excerpt_length');

谢谢,

0 个答案:

没有答案