Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress性能困境_Php_Wordpress_Performance - Fatal编程技术网

Php 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;

我现在担心性能。目前的情况是:

我想显示块编辑器或古腾堡WordPress编辑器中的内容

我创建了一个页面模板并连接到一个页面

<?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; }