阻止在父主题中执行PHP

时间:2014-11-29 作者:JMF

我已经设置了一个子主题,可以对我的网站进行自定义更改,而不会在每次更新时将其删除。一个更改是删除一个包装器,该包装器在“content hero.php”文件中显示页面标题,周围有大量空白。父文件中的代码为:

<div class="hero <?php echo edin_additional_class(); ?>">
<?php if ( ! is_page_template( \'page-templates/front-page.php\' ) ) : ?>

    <?php the_title( \'<div class="hero-wrapper"><h1 class="page-title">\', \'</h1></div>\' ); ?>

<?php else : ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <?php
            if ( 1 == get_theme_mod( \'edin_title_front_page\' ) ) {
                the_title( \'<header class="entry-header"><h1 class="page-title">\', \'</h1></header>\' );
            }
        ?>
        <div class="entry-content">
            <?php the_content(); ?>
            <?php
                wp_link_pages( array(
                    \'before\'      => \'<div class="page-links">\' . __( \'Pages:\', \'edin\' ),
                    \'after\'       => \'</div>\',
                    \'link_before\' => \'<span>\',
                    \'link_after\'  => \'</span>\',
                ) );
            ?>
        </div><!-- .entry-content -->
        <?php edit_post_link( __( \'Edit\', \'edin\' ), \'<footer class="entry-footer"><span class="edit-link">\', \'</span></footer>\' ); ?>
    </article><!-- #post-## -->

<?php endif; ?>

我只需在父文件中使用<;!----&燃气轮机;

但每次我更新主题时,它都会被删除。是否有我可以在函数中输入的代码。子主题中的php(或style.css)文件来阻止加载?

1 个回复
SO网友:Rarst

不,不幸的是,这是WordPress本机使用的PHP模板固有的局限性。您必须重写此模板文件或包含它的文件,但在任何情况下,都必须在整个文件范围内替换某些内容。

WordPress中没有干净的方法来部分加载模板文件,这是由备用模板引擎中的模板继承概念来处理的。

结束

相关推荐

仅当选中/打开幻灯片放映时才加载lideshow.css文件

我使用<?php if ( get_option(\'mytheme_slider\') == \'checked\') { get_template_part( \'partials/slider/slider-java-script\' ); } ?> 要包含slider java脚本。php模板部分进入我的网站。工作正常。如何包含或加载slider-java-script.css 如果选中了相同的选项,则返回文件?