我想在 CMS 页面和类别页面的描述字段中添加 H1 标题以及描述。
如何删除这些页面的 H1 标题但保留产品页面的 H1 标题?
要从主页中删除标题,您只需添加<referenceBlock name="page.main.title" display="false"/>
您的cms_index_index.xml
. 您还可以在需要的地方使用显示 true 和 false。
看到仍然没有人发布要编辑类别页面的内容,要编辑的 XML 文件位于/vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml
. 要编辑的块与 CMS 页面几乎相同:
<referenceBlock name="page.main.title" display="false">
如果您只是进入管理员并转到内容 > 页面并单击主页(或任何页面)上的编辑,则有一个名为设计的部分,您可以在其中粘贴您要执行的 xml。在这种情况下,如果您添加:<referenceBlock name="page.main.title" remove="true" />
它将从主页中删除标题。
您是否在 cms_index_index.xml 中尝试过类似的东西?
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.main.title" remove="true" />
</body>
</page>
要从主页中删除标题,您只需添加<referenceBlock name="page.main.title" display="false"/>
. your cms_index_index.xml
您还可以使用display true
和false
从您想要的地方。
这件事现在对我很有效:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Cms\Block\Page" name="cms_page"/>
</referenceContainer>
<referenceBlock name="page.main.title" remove="true" />
</body>
将此代码放入cms_page_view.cml
只需添加简单的 css
在正文中获取您的页面类并通过添加 css 获取您的页面名称类
. 你的页面名称 .page_title h1 {display:none; }
你的问题很简单....