在Wordpress中对页面上的单独元素进行样式化

时间:2021-03-01 14:10:34

Using Wordpress I am designing a theme for a client's website.

使用Wordpress我正在为客户的网站设计一个主题。

I have set the landing/home page to a static page, and I'm using front-page.php as the default template for this.

我已将登陆/主页设置为静态页面,我使用front-page.php作为此默认模板。

My question is how can I style individual elements on the page when all of the page content is called in at once using <?php get_template_part( 'template-parts/content', get_post_format() ); ?>

我的问题是,当使用

Currently I multiple <div>'s in the WP page content editor like so:

目前我在WP页面内容编辑器中有多个

,如下所示:

在Wordpress中对页面上的单独元素进行样式化

However, I'm concerned that my client or something else, may delete this content by accident and completely spoil the design. How can I separate content and style it accordingly in my template?

但是,我担心我的客户或其他东西可能会意外删除此内容并完全破坏设计。如何在模板中相应地分隔内容并对其进行样式设置?

2 个解决方案

#1


1  

My question is how can I style individual elements on the page?

我的问题是如何在页面上设置单个元素的样式?

There are always body classes you can use for different pages/posts.

总有一些身体类可以用于不同的页面/帖子。

How can I separate content and style it accordingly in my template?

如何在模板中相应地分隔内容并对其进行样式设置?

There are few options depend on what you need:

几乎没有选择取决于您的需求:

  • Turn off "Visual" editor mode for each user account. It sort of helps.

    关闭每个用户帐户的“Visual”编辑器模式。这有点帮助。

  • Move the custom HTML into the template files. If that's OK.

    将自定义HTML移动到模板文件中。如果那没关系。

  • Use custom fields, preferably with Advanced custom fields plugin.

    使用自定义字段,最好使用高级自定义字段插件。

#2


0  

For every page,if you need the alone class then function :body_class() : is sufficient.

Syntax :- < body < ?php body_class(); ?> >

and you can also implement the another function : post_class : for the loop class.

Syntax :- < body < ?php post_class(); ?> >

对于每个页面,如果你需要单独的类,那么函数:body_class():就足够了。语法: - >

#1


1  

My question is how can I style individual elements on the page?

我的问题是如何在页面上设置单个元素的样式?

There are always body classes you can use for different pages/posts.

总有一些身体类可以用于不同的页面/帖子。

How can I separate content and style it accordingly in my template?

如何在模板中相应地分隔内容并对其进行样式设置?

There are few options depend on what you need:

几乎没有选择取决于您的需求:

  • Turn off "Visual" editor mode for each user account. It sort of helps.

    关闭每个用户帐户的“Visual”编辑器模式。这有点帮助。

  • Move the custom HTML into the template files. If that's OK.

    将自定义HTML移动到模板文件中。如果那没关系。

  • Use custom fields, preferably with Advanced custom fields plugin.

    使用自定义字段,最好使用高级自定义字段插件。

#2


0  

For every page,if you need the alone class then function :body_class() : is sufficient.

Syntax :- < body < ?php body_class(); ?> >

and you can also implement the another function : post_class : for the loop class.

Syntax :- < body < ?php post_class(); ?> >

对于每个页面,如果你需要单独的类,那么函数:body_class():就足够了。语法: - >