简体   繁体   English

在Wordpress中修改主题时,当我想删除主题内容时,最好删除CSS或PHP或两者

[英]When modifying a theme in wordpress, when i want to remove theme content is it better to remove CSS or PHP or BOTH

I am doing my website, with studiopress genesis framework and their theme child, now i want to remove some unneccesary header content. 我正在制作带有Studiopress创世纪框架及其主题子项的网站,现在我想删除一些不必要的标题内容。 So I know which code to remove from CSS and which from PHP, is it enought if I only remove CSS and leave PHP, and vice versa, or do I need to remove them both? 因此,我知道要从CSS中删除哪些代码,以及从PHP中删除哪些代码,如果仅删除CSS并保留PHP,反之亦然,还是需要同时删除它们,这足够了吗?

Thank you on help! 谢谢您的帮助!

Because your goal is to REMOVE the content, you have to remove the PHP code with its HTML counterpart. 因为您的目标是删除内容,所以必须删除与HTML对应的PHP代码。 In fact, it's irrelevant whether you remove the CSS or not. 实际上,是否删除CSS无关紧要。 You might use that styling for something else. 您可能会将该样式用于其他内容。

Anders' solution will work well if your goal is to HIDE the content instead of removing it and as he said, you can later on put it back if you like. 如果您的目标是隐藏内容而不是删除内容,则Anders的解决方案将很好地工作,并且正如他所说,您以后可以根据需要将其放回原处。

If you are absolutely sure that you won't need to use that ever again (heck, you can just copy it back from the original theme) and that you also won't need to use the styling, then go ahead and remove both the CSS and the PHP/HTML to keep everything clean. 如果您完全确定不再需要使用该样式(哎呀,您可以将其从原始主题复制回去),并且也不需要使用样式,那么请继续删除这两个样式CSS和PHP / HTML可以使所有内容保持干净。 I would personally do that since I like my code to be looking good :) 我个人会这样做,因为我希望代码看起来不错:)

If you just remove the CSS you will not remove the content, just the formatting. 如果仅删除CSS,则不会删除内容,而只会删除格式。 However, you can hide content using CSS like this: 但是,您可以使用CSS隐藏内容,如下所示:

#id-of-element-you-want-to-remove {
    display: none;
}

The pro of removing content with CSS is that it is quick to do and easy to reverse if you should change your mind. 使用CSS删除内容的优点是,如果您改变主意,它操作起来很快,并且很容易撤消。 The con is that the content is still constructed on the server and sent to the client, so you are wasting both your own resources and those of your visitors. 缺点是内容仍在服务器上构建并发送给客户端,因此您既浪费了自己的资源,也浪费了访问者的资源。 However, if the content is minor this might be a minor thing. 但是,如果内容较小,则可能不重要。

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

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