admin管理员组文章数量:1122826
I've created a custom template using php and would like to know how to modify the content width? Do I have to create a class within php and then modify the width using CSS?
This is how my php template looks right now:
<?php /* Template Name: NewEventTemplate */ ?>
<?php
/**
* The template for displaying pages.
*
* @package Salient WordPress Theme
* @version 10.5
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
get_header();
nectar_page_header( $post->ID );
$nectar_fp_options = nectar_get_full_page_options();
?>
<div class="container-wrap">
<div class="<?php if ( $nectar_fp_options['page_full_screen_rows'] !== 'on' ) { echo 'container'; } ?> main-content">
<div class="row">
</div>
<header class="entry-header">
<?php the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<?php
nectar_hook_before_content();
the_content();
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
the_content();
endwhile;
endif;
nectar_hook_after_content();
?>
</div><!--/row-->
</div><!--/container-->
</div><!--/container-wrap-->
<?php get_footer(); ?>
I've created a custom template using php and would like to know how to modify the content width? Do I have to create a class within php and then modify the width using CSS?
This is how my php template looks right now:
<?php /* Template Name: NewEventTemplate */ ?>
<?php
/**
* The template for displaying pages.
*
* @package Salient WordPress Theme
* @version 10.5
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
get_header();
nectar_page_header( $post->ID );
$nectar_fp_options = nectar_get_full_page_options();
?>
<div class="container-wrap">
<div class="<?php if ( $nectar_fp_options['page_full_screen_rows'] !== 'on' ) { echo 'container'; } ?> main-content">
<div class="row">
</div>
<header class="entry-header">
<?php the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<?php
nectar_hook_before_content();
the_content();
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
the_content();
endwhile;
endif;
nectar_hook_after_content();
?>
</div><!--/row-->
</div><!--/container-->
</div><!--/container-wrap-->
<?php get_footer(); ?>
Share
Improve this question
asked May 7, 2020 at 3:29
royroroyro
1
1
- There's no trick. Just HTML and CSS, like any other webpage. – Jacob Peattie Commented May 7, 2020 at 3:37
1 Answer
Reset to default 0Yes, often the best way is as you describe. In your template file add something like this:
<div class="container-wrap se-366024">
Then in your style.css
(or any other enqueued stylesheet)
.se-366024 {
width:960px;
}
If you are wanting to set a max width across the site you may want to look into the $content_width
global supported by Core and many plugins:
- https://developer.wordpress.com/themes/content-width/
- https://codex.wordpress.org/Content_Width
本文标签: How to change the content width using php
版权声明:本文标题:How to change the content width using php? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736285740a1927521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论