龙空技术网

wordpress小白技巧 - 隐藏特定文章和页面的标题(中英对照)

辽观CathayViews 104

前言:

眼前我们对“onclickcss”都比较注重,咱们都需要剖析一些“onclickcss”的相关文章。那么小编同时在网络上搜集了一些有关“onclickcss””的相关知识,希望同学们能喜欢,大家一起来了解一下吧!

原文链接:How to Hide Title for Selective WordPress Posts and Pages

原文标题:How to Hide the Title for Selective WordPress Posts and Pages

由辽观进行翻译整理。

Do you want to hide the title for selective WordPress posts and pages?

您想要隐藏特定的WordPress文章和页面的标题吗?

Titles can be helpful for both search engines and visitors, but not every page needs to display a title depending on its design.

标题对于搜索引擎和访问者都很有帮助,但并非每个页面都需要根据其设计显示标题。

In this article, we will show you how to hide the title for specific WordPress posts and pages.

在这篇文章中,我们将向您展示如何隐藏特定的WordPress文章和页面的标题。

Why Hide the Title on Specific WordPress Posts or Pages? 为什么要在特定的WordPress文章或页面上隐藏标题呢?

When you create a WordPress page or post the first thing you’ll see is an ‘Add title’ field where you will type your title.

当您创建WordPress页面或文章时,您首先会看到一个“添加标题”的字段,您可以在其中键入标题。

Most WordPress themes show this title at the top of the page or post. A descriptive, relevant title can let visitors know they’re in the right place and what to expect from this page.

大多数WordPress主题会在页面或文章的顶部显示这个标题。一个描述性的、相关的标题可以让访问者知道他们来到了正确的地方,并且可以对这个页面有所期待。

Titles may be helpful, but not every page or post needs a title. Your website’s homepage is one common example.

标题可能是有帮助的,但并不是每个页面或文章都需要标题。您网站的首页就是一个常见的例子。

At other times you may want to show the page’s title in a different area. For example you might start your landing page with an eye-catching banner, and then show the title further down the page.

在其他情况下,您可能希望在不同的区显示页面的标题。例如,您可能会在引人注目的横幅上开始您的登陆页面,然后在页面下方显示标题。

In this guide, we’ll be covering three different methods to hide the post or page title in WordPress. Simply click the links below to jump to the method you prefer.

在本指南中,我们将介绍三种在WordPress中隐藏帖子或页面标题的不同方法。只需点击面的链接,跳转到您喜欢的方法。

Method 1: Remove All Post Titles in the Full Site Editor

方法1:在全站编辑器中删除所有帖子标题Method 2. Hide Titles on Specific Posts or Pages Using CSS

方法2:使用CSS隐藏特定帖子或页面的标题Method 3. Hiding Selective WordPress Titles Using a Plugin

方法3:使用插件隐藏选择性的WordPress标题Method 4. Hiding Selective WordPress Titles in Custom Page Designs

方法4:在自定义页面设计中隐藏选择性的WordPress标题Method 1: Remove Post Title Using Full Site Editor方法1:在全站编辑器中删除所有帖子标题

If you’re using WordPress 5.9 or later, and have aWordPress themethat supports full site editing, then you can use this method to remove the title from all posts or all pages.

如果您使用的是WordPress 5.9或更高版本,并且拥有一个支持全站编辑的WordPress主题,那么您可以使用这种方法来删除所有帖子或页面的标题。

Not sure if your theme support full site editing?

不确定您的主题是否支持全站编辑?

If it does, then you’ll see the menu optionAppearance » Editoravailable in your WordPress dashboard.

如果支持全站编辑,您将在WordPress仪表板中看到菜单选项“外观 » 编辑器”。

After clicking on ‘Editor’, the full site editor will launch.

点击“编辑器”后,将启动全站编辑器。

From here, you’ll need to select thetemplateyou want to edit by clicking on the dropdown at the top of the page, and then clicking on ‘Browse all templates’.

在这里,您需要通过点击页面顶部的下拉菜单,并点击“浏览所有模板”,来选择您想要编辑的模板。

In this example, we’ll edit the Single Post template so that we can hide all our blog post titles.

在这个例子中,我们将编辑单篇文章模板,以便隐藏所有博客文章的标题。

To hide the title, first you’ll need to click on the blog post title. Then, simply click on the three dots options menu and select the ‘Remove Post Title’ option at the bottom.

要隐藏标题,首先需要点击博客文章的标题。然后,只需点击三个点的选项菜单,并在底部选择“删除文章标题”选项。

Don’t forget to click the Save button at the top of the screen after you’re done customizing the template.

在您完成对模板进行自定义后,不要忘记点击屏幕顶部的保存按钮。

That’s it, you’ve hidden the title on all your blog posts.

完成了!您已经在所有博客文章中隐藏了标题。

If you’d like a way to hide the title only on specific posts or pages, the next method should work for you.

如果您想要仅在特定的文章或页面上隐藏标题,下一种方法可能适合您。

Method 2: Hiding Selective WordPress Titles Using CSS方法2:使用CSS隐藏特定帖子或页面的标题

You can hide a page or post’s title by adding custom CSS code to theWordPress Customizer. This method simply hides the title from your visitors, but it still loads in the page’s HTML code.

您可以通过向WordPress自定义器添加自定义CSS代码来隐藏页面或文章的标题。这种方法只是从访客的视野中隐藏标题,但它仍然会在页面的HTML代码中加载。

This means that search engines can still use the title to help them understand your page’s contents, which is good for yourWordPress website’s SEOand can help you get more traffic.

这意味着搜索引擎仍然可以使用标题来帮助它们理解您页面的内容,这对于您的WordPress网站的SEO非常有益,可以帮助您获得更多的流量。

We’ll show you how to hide the title on specific posts or pages, or on all your posts and pages.

我们将向您展示如何在特定的文章或页面上隐藏标题,或者在所有文章和页面上都隐藏标题。

2.1 How to Hide the Title on a Specific WordPress Post or Page With CSS如何使用CSS在特定的WordPress文章或页面上隐藏标题

To hide a page or post’s title using CSS, you just need to know its ID.

要使用CSS隐藏页面或文章的标题,您只需要知道它的ID。

In your WordPress dashboard, either go toPosts » All Posts, orPages » All Pages. Then find the page or post where you want to hide the title.

在WordPress仪表板中,要么转到“文章” » “所有文章”,要么转到“页面” » “所有页面”。然后找到您想要隐藏标题的页面或文章。

You can now open this post or page for editing.

您现在可以打开此文章或页面进行编辑。

Now simply take a look at the URL in your browser’s address bar.

现在只需查看浏览器地址栏中的URL。

You should see a ‘post=’ section followed by a number. For example ‘post=100.’

您应该看到一个由数字跟随的“post=”部分。例如,“post=100”。

This is your post’s ID. Make a note of this number, as you’ll be using it in your CSS code.

这是您的文章的ID。请记下这个数字,因为您将在CSS代码中使用它。

You can now go to Appearance » Customize.

现在您可以转到“外观” » “自定义”。

This launches the WordPress Customizer.

这将启动WordPress自定义器。

In the sidebar, simply click on Additional CSS.

在侧边栏中,只需单击“附加CSS”。

Now scroll to the bottom of the sidebar.

现在滚动到侧边栏底部。

You should now see a small text editor. This is where you’ll type your CSS code.

您现在应该看到一个小型文本编辑器。这是您输入CSS代码的地方。

If you want to hide the title for a post, you’ll need to use the following code.

如果您想隐藏文章的标题,您需要使用以下代码。

Just make sure you replace the ‘100’ with the post ID you got in the previous step.

只需确保将“100”替换为您在前一步骤中获得的文章ID。

.postid-100 .entry-title {display: none;}

If you want to hide a page’s title, you’ll need to use some slightly different code.

如果您想隐藏页面的标题,您需要使用略有不同的代码。

Once again make sure you replace the ‘100’ with your real page ID.

如果您想隐藏页面的标题,您需要使用略有不同的代码。

.page-id-100 .entry-title {display: none;}

Next, just scroll to the top of the page.

接下来,将页面滚动到顶部。

You can then click on the blue Publish button.

然后,您可以点击蓝色的“发布”按钮。

Now if you check this page or post, the title should have disappeared.

现在,如果您检查此页面或文章,标题应该已经消失了。

Is the title still there?

标题还在吗?

If this method hasn’t worked for you, your WordPress theme may be using a different CSS class. This means your page or post ID will be different from the number shown in its URL.

如果这种方法对您不起作用,那么您的WordPress主题可能正在使用不同的CSS类。这意味着您的页面或文章ID将与其URL中显示的数字不同。

To get the correct ID, you’ll need to use your browser’s developer console.

要获取正确的ID,您需要使用浏览器的开发者控制台。

To start, head over to the page or post on your WordPress website. You can then open your browser’s developer console.

首先,转到WordPress网站上的页面或文章。然后,您可以打开浏览器的开发者控制台。

This step will vary depending on which web browser you’re using. For example, if you have Chrome then you can use the Control+Shift+J keyboard shortcut on Windows, or the Command+Option+J shortcut on Mac.

这一步骤会根据您使用的Web浏览器而有所不同。例如,如果您使用的是Chrome浏览器,您可以在Windows上使用Control+Shift+J键盘快捷键,或者在Mac上使用Command+Option+J快捷键。

Chrome users can also Control+click anywhere on the page or post, and then select Inspect.

Chrome用户还可以在页面或文章的任何位置Control+点击,然后选择”Inspect“。

If you’re unsure how to open the developer console, you can always check your browser’s website or official documentation for more information.

如果您不知道如何打开开发者控制台,您可以随时查看浏览器的网站或官方文档以获取更多信息。

In the developer console, click on the three dotted icon. You can then select ‘Search.’

在开发者控制台中,点击三个点的图标。然后,您可以选择“搜索”。

You should now see a search bar towards the bottom of the developer console.

现在,您应该会在开发者控制台的底部看到一个搜索栏。

In this bar, type <body class, then simply press the Enter key on your keyboard.

在此栏中,键入<body class,然后只需按下键盘上的Enter键。

If you’re looking at a WordPress page, you should see something similar to the following.

如果您正在查看一个WordPress页面,您应该会看到类似以下的内容。

<body class="page-template-default page page-id-78 logged-in admin-bar no-customize-support wp-embed-responsive is-light-theme no-js singular">

In the sample code above, you can see that the ‘page-id’ value is 78.

在上面的示例代码中,可以看到"page-id"的值为78。

If you’re inspecting a WordPress post, the console should show something like:

如果您在检查WordPress文章,控制台应该显示类似以下内容:

<body class="post-template-default single single-post postid-100 single-format-standard logged-in admin-bar no-customize-support wp-embed-responsive is-light-theme no-js singular">

In that example, the ‘postid’ value is 100. You can now use this value with the CSS code we provided in the previous step.

在这个示例中,"postid"的值为100。您现在可以将这个值与我们在上一步中提供的CSS代码一起使用。

Simply add this code to your website using the WordPress Customizer, following the process described above.

只需按照上述描述的过程,使用WordPress自定义器将此代码添加到您的网站上即可。

You can now take a look at the page or post. The title should have vanished.

您现在可以查看页面或文章。标题应该已经消失了。

2.2 How to Hide the Title on All Posts or Pages with CSS如何使用CSS隐藏所有帖子或页面的标题

To hide the titles for all your pages and posts, copy/paste the following into the text editor.

要隐藏所有页面和帖子的标题,请将以下内容复制/粘贴到文本编辑器中。

.entry-title {display: none;} 

Do you want to hide the titles for all your pages, but not your posts? To hide all the page titles, copy/paste the following into the small text editor.

您想要隐藏所有页面的标题,但不隐藏帖子的标题吗?为了隐藏所有页面的标题,请将以下内容复制/粘贴到小文本编辑器中。

.page .entry-title {display: none;} 

Another option is hiding the title for all of your posts. You can do this using the following CSS.

另一个选择是隐藏所有帖子的标题。您可以使用以下CSS代码来实现。

.post .entry-title {display: none;} 

Sometimes you may want to hide the titles for all your posts and pages.

有时候您可能希望隐藏所有页面和帖子的标题。

To do that, add the following.

要做到这一点,请添加以下代码。

.entry-title {   display: none; }
Method 3: Hiding Selective WordPress Titles Using a Plugin第三种方法:使用插件隐藏选择性的WordPress标题

You can easily hide the title for selective posts and posts using Hide Page And Post Title. This free plugin lets you hide the title of any page, post, or even custom posts types.

您可以使用Hide Page And Post Title轻松地隐藏选择性的页面和帖子的标题。这个免费插件允许您隐藏任何页面、帖子,甚至自定义帖子类型的标题。

译者注:请注意,隐藏标题后,页面或帖子的标题将不再显示在前台,但标题仍然存在于后台编辑界面,您可以随时修改和恢复标题的显示。

First you’ll need to install and activate the Hide Page And Post Title plugin. If you need help, you can follow our tutorial on how to install a WordPress plugin.

首先,您需要安装并激活Hide Page And Post Title插件。如果需要帮助,您可以按照我们的WordPress插件安装教程进行操作。

Upon activation, open the page, post or custom post you want to edit.

在激活插件后,打开您想要编辑的页面、帖子或自定义帖子。

Now simply scroll to the bottom of the right sidebar.

现在只需要向右边栏的底部滚动。

Here you’ll find a new ‘Hide Page and Post Title’ box.

在这里,您会找到一个名为“隐藏页面和帖子标题”的新框。

译者注:请注意,这个框可能在编辑页面或帖子的不同位置,具体取决于您的主题或其他插件的设置。通常,您可以在编辑页面或帖子的右侧边栏或编辑器中找到该框。

To hide the title, just click to select the ‘Hide the title’ checkbox. You can then update or publish this post as normal.

要隐藏标题,只需点击选择“隐藏标题”复选框。然后,您可以像正常编辑页面或发布帖子一样更新或发布。

That’s it! If you visit the page you’ll notice that the title has disappeared.

就是这样!如果您访问该页面,您会注意到标题已经消失了。

At some point you may need to restore this page or post’s title.

在某些时候,您可能需要恢复该页面或帖子的标题。

This is easy. Just open the page or post for editing. Then click to deselect the same ‘Hide the title’ checkbox.

这很简单。只需打开要编辑的页面或帖子。然后点击取消选择相同的“隐藏标题”复选框。

Don’t forget to click on the Update button at the top of the screen. Now if you visit this page, the title should have reappeared.

不要忘记点击屏幕顶部的“更新”按钮。现在,如果您访问此页面,标题应该已经重新出现。

Method 4: Hiding Selective WordPress Titles Using SeedProd方法四:使用SeedProd隐藏选择性的WordPress标题

Another option is to hide the title using a page builder plugin.

另一个选项是使用页面构建器插件隐藏标题。

SeedProd is the best WordPress page builder plugin in the market. You can use this plugin to easily creating custom pages or even create your own WordPress theme.

SeedProd是市场上最好的WordPress页面构建器插件。您可以使用这个插件轻松创建自定义页面,甚至创建自己的WordPress主题。

This means you can easily hide the title on a custom page design or your theme.

这意味着您可以轻松地在自定义页面设计或您的主题中隐藏标题。

SeedProd comes with a template library with over 150+ templates you can use as a starting point for your page designs. Let’s see how easy it is to remove the title from one of these theme templates.

SeedProd附带了一个模板库,其中包含150多个模板,您可以用作页面设计的起点。让我们看看如何从其中一个主题模板中删除标题。

In your WordPress dashboard go to SeedProd » Template Builder. You can then click on the Themes button.

在WordPress仪表板中,转到SeedProd » 模板构建器。然后,您可以点击主题按钮。

This launches the SeedProd template library. You can now browse through all of the different designs.

这将启动SeedProd模板库。您现在可以浏览所有不同的设计。

To take a closer look at a template simply hover your mouse over it. Then click on the magnifying glass icon.

要仔细查看模板,只需将鼠标悬停在其上,然后点击放大镜图标。

This will open the template in a new tab.

这将在一个新标签中打开模板。

When you find a template that you want to use, hover your mouse over that template. Then simply click on the checkmark icon.

当您找到一个要使用的模板时,将鼠标悬停在该模板上。然后只需点击复选标记图标即可。

This adds all of this template’s designs to your WordPress dashboard.

这将把这个模板的所有设计添加到您的WordPress仪表板中。

There are usually different designs for different types of content.

通常针对不同类型的内容有不同的设计。

You can use these templates to hide the title for the different content types. For example, many SeedProd templates have a separate design for the homepage.

您可以使用这些模板来隐藏不同内容类型的标题。例如,许多SeedProd模板都有一个专门的设计用于首页。

To hide the title for your homepage, you would simply need to edit the Homepage template.

要隐藏首页的标题,您只需要编辑首页模板即可。

To hide the title for all your posts, you’ll typically need to edit the Single Post template.

要隐藏所有文章的标题,通常需要编辑Single Post模板。

Meanwhile if you want to hide the title from your pages you’ll usually edit SeedProd’s Single Page template.

而如果您想隐藏页面的标题,则通常需要编辑SeedProd的Single Page模板。

To edit a template hover your mouse over it.

要编辑模板,请将鼠标悬停在模板上。

You can then go ahead and click on the Edit Design link.

然后,您可以点击“编辑设计”链接进行编辑。

This opens this design in the SeedProd drag and drop editor. To hide the title, find either the Post or Page Title.

这将在SeedProd的拖放编辑器中打开此设计。要隐藏标题,请找到“文章标题”或“页面标题”。

Once you spot this title, give it a click. SeedProd’s sidebar will now show all of the settings for the selected area.

一旦找到标题,请点击它。SeedProd的侧边栏将显示所选区域的所有设置。

At the top of this panel you should see either Post Title or Page Title.

在这个面板的顶部,您应该看到“文章标题”或“页面标题”。

After confirming that you’ve selected the right area, hover over the Post Title or Page Title in the main SeedProd editor.

确认选择了正确的区域后,在主SeedProd编辑器中将鼠标悬停在“文章标题”或“页面标题”上。

You should now see a row of controls.

现在您应该看到一行控件。

To remove the title from this design just click on the Trash icon.

要从此设计中删除标题,只需点击垃圾桶图标。

SeedProd will ask whether you really want to delete the title. To go ahead and remove it, simply click on ‘Yes, delete it!’

SeedProd将询问您是否真的要删除标题。要继续删除,请点击“是,删除它!”

The title will now disappear from your design.

标题现在将从您的设计中消失。

To see how this will look on your website click on the Preview button.

要查看它在您的网站上的效果,请点击“预览”按钮。

When you’re happy with your design click on the Publish button.

当您对设计满意时,请点击“发布”按钮。

Depending on how your site is set up, you may need to remove the title from some additional templates. For example you might want to hide the title for all your posts and pages. In this case, you would typically need to edit both the Single Post and Single Page templates.

根据您的网站设置,您可能需要从一些额外的模板中删除标题。例如,您可能希望隐藏所有文章和页面的标题。在这种情况下,您通常需要编辑单篇文章和单页模板。

If you’re unsure then it may help to review all the designs that make up your theme. To do this simply go to SeedProd » Theme Builder.

如果您不确定,可以检查一下组成您主题的所有设计。只需转到SeedProd » 主题构建器。

You should now see a list of all your different designs. You can now edit any of these templates following the same process described above.

您现在应该可以看到所有不同设计的列表。您现在可以按照上面描述的相同步骤编辑任何这些模板。

FAQs About Hiding the Title for Selective Pages and Posts有关选择性隐藏页面和文章标题的常见问题

Before hiding your page or post titles, there are some effects you should think about, such as the impact this action will have on your website’s SEO.

在隐藏页面或文章标题之前,您应该考虑一些影响,比如此操作对您的网站SEO的影响。

That being said, here are some of the most frequently asked questions about hiding the page and post title.

话虽如此,以下是关于隐藏页面和文章标题的一些常见问题:

Why can’t I just leave the ‘Add title’ field blank?为什么我不能只是将“添加标题”字段留空?

When it comes to hiding the title there seems like an easy fix. As you’re creating your page, just leave the title field blank.

在隐藏标题方面,似乎有一个简单的解决方法。在创建页面时,只需将标题字段留空即可。

At first this does seem to fix the problem. WordPress will display this post to visitors without a title. However, there are a few problems.

起初,这似乎解决了问题。WordPress将在没有标题的情况下向访问者显示此页面或文章。然而,确实存在一些问题。

Firstly, this page or post will appear as ‘(no title)’ in your WordPress dashboard. This makes it more difficult to keep track of your pages.

首先,在WordPress仪表板中,该页面或文章将显示为“(no title)”(无标题)。这使得跟踪页面变得更加困难。

If you create lots of different ‘(no title)’ posts, then how do you know which is your contact us page? And which page is your homepage?

如果您创建了许多不同的“(no title)”文章,那么您如何知道哪个是您的联系我们页面?哪个是您的首页?

WordPress also uses the title to create the page’s URL.

WordPress还使用标题来创建页面的URL。

If you don’t provide a title, then by default WordPress uses a number instead, such as ‘.’

如果您不提供,WordPress默认使用一个数字,“wwwwebsite/8”。

Visitors often use the URL to help them understand where they are on your WordPress website, so ‘’ isn’t particularly helpful.

访问者通常使用URL来帮助他们理解自己在WordPress网站上的位置,“”并不特别有帮助。

This vague URL is not an SEO-friendly permalink, so search engines may have a harder time understanding what your content is about and including it in the relevant search results.

这种模糊的URL不是一个友好的SEO永久链接,所以搜索引擎可能很难理解您的内容是关于什么,并将其包含在相关的搜索结果中。

Will hiding the page or post title affect my SEO?隐藏页面或文章标题可能会对您的SEO产生影响。

If you prefer to hide a page or post’s title, you’ll want to spend some extra time fine-tuning the rest of your WordPress SEO, including setting an SEO title. This will help ensure that the search engines understand your page’s content, even without the title.

如果您希望隐藏页面或文章的标题,您需要额外花费一些时间来优化您的WordPress SEO,包括设置SEO标题。这样可以确保搜索引擎即使没有标题也能理解页面的内容。

Here you’ll need a good SEO plugin, since WordPress doesn’t let you do this by default.

在这里,您将需要一个好的SEO插件,因为WordPress默认情况下不允许您这样做。

We recommend using AIOSEO, the best SEO plugin for WordPress in the market. This beginner friendly SEO toolkit is used by over 3 million websites.

我们推荐使用AIOSEO,这是市场上最好的WordPress SEO插件。这个适合初学者的SEO工具包被超过300万个网站使用。

If you need help getting started, then please refer to our guide on how to properly set up All in One SEO in WordPress.

如果您需要帮助入门,请参考我们的指南,了解如何正确设置WordPress中的All in One SEO。

To make sure your titles are optimized, you can see our guide on how to use the headline analyzer in AIOSEO.

为了确保您的标题被优化,您可以参考我们的指南,了解如何使用AIOSEO中的标题分析器。

We hope this article helped you learn how to hide the title for selective WordPress posts and pages. You can also go through our guide on how to choose the best web design software, and the best WordPress landing page plugins.

我们希望本文能帮助您学习如何隐藏选择性WordPress文章和页面的标题。您还可以阅读我们的指南,了解如何选择最佳的网页设计软件和最佳的WordPress落地页插件。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道,观看WordPress视频教程。您也可以在Twitter和Facebook上找到我们。

标签: #onclickcss