Php WordPress性能困境
我现在担心性能。目前的情况是: 我想显示块编辑器或古腾堡WordPress编辑器中的内容 我创建了一个页面模板并连接到一个页面Php WordPress性能困境,php,wordpress,performance,Php,Wordpress,Performance,我现在担心性能。目前的情况是: 我想显示块编辑器或古腾堡WordPress编辑器中的内容 我创建了一个页面模板并连接到一个页面 <?php /* Template Name: Example Template */ ?> <?php get_header(); ?> <?php while(have_posts()) : the_post(); ?> <?php the_content();?> <?php endwhile;
<?php /* Template Name: Example Template */ ?>
<?php get_header(); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_content();?>
<?php endwhile; ?>
<?php get_footer(); ?>
从_content()添加元素的最佳方式是什么强壮>有趣。上课
我想标题标签有一个示例类,但段落标签有其他的。
我有三个办法来“解决”这个问题
第一:
通过CSS在页面模板和目标元素中添加样式标记
<?php /* Template Name: Example Template */ ?>
<style>
.main h1 { color: red; } .main p { color: green; }
</style>
<?php get_header(); ?>
<?php while(have_posts()) : the_post(); ?>
<div class="main">
<?php the_content();?>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>
.main h1{颜色:红色;}.main p{颜色:绿色;}
第二:
通过jQuery添加目标类
$(“h1”).addClass(“红色”);
$(“p”).addClass(“绿色”);
或者从Gutenberg编辑器添加一个类。但我不确定,如果用户删除整个元素会怎么样。不仅仅是内容。在我看来,越简单越好
我会使用主题的style.css
文件或另一个已经存在的文件,只向模板中的main
div添加一个类(example
class)
如果我为标题或段落定义了类呢?
<?php /* Template Name: Example Template */ ?>
<?php get_header(); ?>
<?php while(have_posts()) : the_post(); ?>
<div class="main example">
<?php the_content();?>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>
.main.example h1 { color: red; }
.main.example p { color: green; }