繁体   English   中英

Wordpress主题的全宽模板

[英]Full Width template for Wordpress theme

我在Wordpress网站上添加了一个全宽模板页面,以便在一个页面上使用: http : //pjstagingdecorating.com/portfolio-testing2/#DTprettyPhoto

我在样式表中添加了一个新的PHP文件以及CSS。 模板确实作为一个选项出现,但是内容不会出现在页面的整个宽度上。 下面的PHP和CSS。

<?php
/**
 * Template Name: Full Width
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that other
 * 'pages' on your WordPress site will use a different template.
 *
 * @package WordPress
 * @subpackage Twenty_Thirteen
 * @since Twenty Thirteen 1.0
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php /* The loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <header class="entry-header full-width">
                        <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
                        <div class="entry-thumbnail">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <?php endif; ?>

                        <?php if (is_front_page()) : ?>
<?php else : ?>
<h1 class="entry-title full-width"><?php the_title(); ?></h1>
<?php endif; ?>
                    </header><!-- .entry-header -->

                    <div class="entry-content full-width">
                        <?php the_content(); ?>
                        <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
                    </div><!-- .entry-content -->

                    <footer class="entry-meta">
                        <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
                    </footer><!-- .entry-meta -->
                </article><!-- #post -->

            <?php endwhile; ?>

        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_footer(); ?> 

和CSS:

.full-width {
    margin-left: auto !important;
    margin-right: auto !important;
    height: auto;
    padding-right: 1em !important;
}

对我在做什么错有任何想法吗? 谢谢!

将此添加到ur css文件:

.page-template-fullwidth .div#primary, .page-template-fullwidth .hentry {max-width:100%!important;}

建议创建子主题以修改Wordpress主题,否则在更新主题时将重置您的更改。 您可以按照以下指南创建子主题: http : //variablez.com/wordpress/how-to-create-a-wordpress-child-theme

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM