總是有人會(huì)說Javascript很簡單,很容易學(xué),但我卻不這么認(rèn)為,因?yàn)槠湔Z言的靈活性,在學(xué)習(xí)的時(shí)候總會(huì)遇到這樣或那樣的坑,今天我們就看幾道Javascript的題目,看看你們是不是都會(huì)做吧?
Javascript
我們直接通過代碼去看題目,大家可以自行看看輸出的結(jié)果。
題目1
題目1輸出結(jié)果為undefined,這道題考察的是Javascript中變量提升知識點(diǎn)。
變量提升表示的是變量的聲明會(huì)被提前到函數(shù)頂部的地方,而賦值語句不會(huì)提升。因此上面的題目實(shí)際是等于下面的代碼。
變量提升
變量a提升到頂部,第一句就相當(dāng)于window.a=undefined,所以在下面的if語句中,判斷條件始終為false,因此a=1不會(huì)執(zhí)行,最終輸出undefined。
下面是題目2的代碼。
題目2
題目2輸出的結(jié)果為1。
這道題考察的知識點(diǎn)是具名函數(shù)表達(dá)式。具名函數(shù)表達(dá)式是不存在變量提升的,所以函數(shù)的定義不會(huì)被提前到頂部;而且具名函數(shù)表達(dá)式的名字在外部訪問時(shí)會(huì)報(bào)錯(cuò),只能在函數(shù)內(nèi)部訪問到。我們可以看看下面的例子。
具名函數(shù)使用
題目3的代碼如下。
題目3
題目3輸出的結(jié)果為function。
這道題考察的知識點(diǎn)是函數(shù)聲明和變量聲明。需要記住的一點(diǎn)就是,在Javascript中,函數(shù)聲明的優(yōu)先級高于變量聲明的優(yōu)先級。
因此在上述的題目中,由于優(yōu)先級的問題,a會(huì)被定義為一個(gè)函數(shù),后面定義的變量不會(huì)生效,因此typeof的時(shí)候會(huì)返回function。
但是,需要注意的是,雖然函數(shù)聲明會(huì)覆蓋變量聲明,但不會(huì)覆蓋變量的賦值,我們將上面的代碼改一下,就會(huì)發(fā)現(xiàn)這個(gè)特點(diǎn)。
改變后
上面的代碼會(huì)返回number。因?yàn)橘x值語句a=1不會(huì)被覆蓋,所以a會(huì)是一個(gè)數(shù)字,而不是函數(shù),最終返回number。
題目4的代碼如下。
題目4
題目4返回結(jié)果是10。
這道題考察的是arguments對象,如果看了我昨天寫的一篇文章《解讀JS中的arguments對象,來學(xué)習(xí)一下吧?》應(yīng)該會(huì)很容易理解。
但是,需要注意一種特殊情況,那就是嚴(yán)格模式。在嚴(yán)格模式下,arguments對象實(shí)際是函數(shù)參數(shù)的一個(gè)拷貝,實(shí)際指向的是不同的內(nèi)存空間,對arguments值的改變并不會(huì)影響到函數(shù)參數(shù)值。
嚴(yán)格模式下的arguments對象
題目5的代碼如下。
題目5
題目返回的結(jié)果是Window對象。
這道題目考察的call方法。在Javascript中,如果給call方法傳遞的第一個(gè)參數(shù)為null或者undefined,那么call方法中this會(huì)指向全局對象。
在瀏覽器環(huán)境中,全局對象為Window;而在Nodejs環(huán)境中全局對象為Global。因此上述代碼如果在瀏覽器下運(yùn)行,會(huì)返回Window對象。
今天將的是幾個(gè)簡單但容易被忽略的Javascript題目,大家有收獲嗎?
HTML作為前端三大基礎(chǔ)知識點(diǎn)之一,是每一個(gè)前端開發(fā)人員都要掌握的部分。今天這篇文章我們來看看一些平時(shí)不太會(huì)注意,卻在面試時(shí)可能會(huì)問到的題目,來看看你都會(huì)嗎?
HTML
我們都知道textarea是form表單中一個(gè)很常見的元素,用于多行文本輸入,可以設(shè)置行數(shù)和列數(shù)。
但是默認(rèn)的textarea樣式在頁面上看起來是很丑的,很多頁面都是采用div模擬textarea實(shí)現(xiàn)。例如QQ空間主頁面的發(fā)表說說,在你看頁面源碼后就會(huì)發(fā)現(xiàn)這個(gè)輸入框其實(shí)是一個(gè)div元素,并不是一個(gè)textarea元素,現(xiàn)在我們就來看看這是如何實(shí)現(xiàn)的吧?
首先來看看實(shí)現(xiàn)的效果是什么樣的。
實(shí)現(xiàn)效果
關(guān)鍵屬性:contenteditable
正如這個(gè)屬性的字面意思,可以理解為可編輯的,如果在頁面標(biāo)簽上設(shè)置contenteditable=true,該標(biāo)簽就可以進(jìn)行編輯了。
可以配合user-modify屬性,該屬性表示的是控制用戶能否對頁面元素進(jìn)行編輯,通過設(shè)置不同的值可以選擇富文本或者純文本內(nèi)容,但是由于該屬性是非標(biāo)準(zhǔn)屬性,很少有人知道。
首先我們來看看頁面的HTML部分代碼,就是一個(gè)很簡單的div標(biāo)簽,然后設(shè)置contenteditable屬性為true。
HTML部分代碼
接下來我們就看看整個(gè)CSS代碼的完整實(shí)現(xiàn)吧。
CSS樣式
通過min-height和max-height屬性可以控制div的高度,在內(nèi)容超出max-height后會(huì)出現(xiàn)滾動(dòng)條。如果想要固定div的高度,則只需要設(shè)置height屬性就可以,而不用設(shè)置min-height和max-height屬性。
src和href從使用上來看都是對外部資源的一種引用,但是在具體理解上是有差異的。
href的值指定的是資源在網(wǎng)絡(luò)上的位置,定義的是當(dāng)前頁面上的某個(gè)元素與需要的資源文件的一個(gè)鏈接。比如下面一個(gè)語句。
href引用
當(dāng)瀏覽器解析到頁面的這條語句時(shí),會(huì)知道在這里引用了一個(gè)外部樣式文件,但并不會(huì)阻止頁面解析。這與@import有很大不同,因此在引入外部樣式時(shí),推薦使用link標(biāo)簽。
src的值表示的是頁面上必不可少的內(nèi)容,需要將指定內(nèi)容加載到當(dāng)前頁面中。比如下面一個(gè)語句。
src引用
當(dāng)瀏覽器解析到頁面上的這條語句時(shí),瀏覽器會(huì)對這個(gè)文件進(jìn)行解析,編譯和執(zhí)行,從而導(dǎo)致整個(gè)頁面加載會(huì)被暫停,這也是為什么一般會(huì)選擇將script標(biāo)簽放在body結(jié)束標(biāo)簽的前面。
有一種更好的理解方式,href表示的是一個(gè)資源的鏈接;src是對當(dāng)前元素的替換,內(nèi)容最終會(huì)嵌入到當(dāng)前頁面中。
雖然目前大多數(shù)網(wǎng)頁都是采用的DIV+CSS布局的方式,但是也有少數(shù)的老式Web網(wǎng)頁采用的是Table布局,我們可以一起來看看兩種布局方式的優(yōu)劣。
布局對比
div+css布局
div+css的布局方式屬于W3C標(biāo)準(zhǔn),而且由于CSS的存在,HTML部分的代碼會(huì)顯得很純凈,滿足行為,樣式,結(jié)構(gòu)分離的原則。
頁面加載速度更快,這是目前DIV+CSS使用更廣泛的一個(gè)非常重要的原因。
頁面編碼量相對于Table布局會(huì)少很多。
頁面內(nèi)容更容易維護(hù),由于樣式都存在CSS文件中,只需要修改CSS文件即可,對HTML文件不會(huì)有影響。
由于DIV+CSS布局更容易進(jìn)行SEO優(yōu)化,所以更方便被搜索引擎收錄。
Table布局
雖然DIV+CSS有各種各樣的優(yōu)勢,但是Table布局也并不是完全無用的。這里也可以列舉出幾個(gè)采用Table布局的優(yōu)勢。
新手學(xué)習(xí)方便(相信有很多后端RD在進(jìn)行前端學(xué)習(xí)時(shí)剛開始都是從table布局開始的)。
兼容性更好,由于Table布局是從最古老的瀏覽器發(fā)展而來的,在兼容性上會(huì)滿足所有瀏覽器。而CSS3的出現(xiàn)卻要考慮瀏覽器的支持程度,一個(gè)樣式要考慮加上幾個(gè)不同瀏覽器前綴,類似于-webkit,-moz等
今天這篇文章主要講解了幾個(gè)關(guān)于HTML的知識點(diǎn),大家都掌握了嗎?
文鏈接:How to Hide Title for Selective WordPress Posts and Pages
原文標(biāo)題:How to Hide the Title for Selective WordPress Posts and Pages
由遼觀進(jìn)行翻譯整理。
Do you want to hide the title for selective WordPress posts and pages?
您想要隱藏特定的WordPress文章和頁面的標(biāo)題嗎?
Titles can be helpful for both search engines and visitors, but not every page needs to display a title depending on its design.
標(biāo)題對于搜索引擎和訪問者都很有幫助,但并非每個(gè)頁面都需要根據(jù)其設(shè)計(jì)顯示標(biāo)題。
In this article, we will show you how to hide the title for specific WordPress posts and pages.
在這篇文章中,我們將向您展示如何隱藏特定的WordPress文章和頁面的標(biāo)題。
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.
當(dāng)您創(chuàng)建WordPress頁面或文章時(shí),您首先會(huì)看到一個(gè)“添加標(biāo)題”的字段,您可以在其中鍵入標(biāo)題。
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.
大多數(shù)WordPress主題會(huì)在頁面或文章的頂部顯示這個(gè)標(biāo)題。一個(gè)描述性的、相關(guān)的標(biāo)題可以讓訪問者知道他們來到了正確的地方,并且可以對這個(gè)頁面有所期待。
Titles may be helpful, but not every page or post needs a title. Your website’s homepage is one common example.
標(biāo)題可能是有幫助的,但并不是每個(gè)頁面或文章都需要標(biāo)題。您網(wǎng)站的首頁就是一個(gè)常見的例子。
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.
在其他情況下,您可能希望在不同的區(qū)顯示頁面的標(biāo)題。例如,您可能會(huì)在引人注目的橫幅上開始您的登陸頁面,然后在頁面下方顯示標(biāo)題。
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中隱藏帖子或頁面標(biāo)題的不同方法。只需點(diǎn)擊面的鏈接,跳轉(zhuǎn)到您喜歡的方法。
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或更高版本,并且擁有一個(gè)支持全站編輯的WordPress主題,那么您可以使用這種方法來刪除所有帖子或頁面的標(biāo)題。
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儀表板中看到菜單選項(xiàng)“外觀 ? 編輯器”。
After clicking on ‘Editor’, the full site editor will launch.
點(diǎn)擊“編輯器”后,將啟動(dòng)全站編輯器。
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’.
在這里,您需要通過點(diǎn)擊頁面頂部的下拉菜單,并點(diǎn)擊“瀏覽所有模板”,來選擇您想要編輯的模板。
In this example, we’ll edit the Single Post template so that we can hide all our blog post titles.
在這個(gè)例子中,我們將編輯單篇文章模板,以便隱藏所有博客文章的標(biāo)題。
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.
要隱藏標(biāo)題,首先需要點(diǎn)擊博客文章的標(biāo)題。然后,只需點(diǎn)擊三個(gè)點(diǎn)的選項(xiàng)菜單,并在底部選擇“刪除文章標(biāo)題”選項(xiàng)。
Don’t forget to click the Save button at the top of the screen after you’re done customizing the template.
在您完成對模板進(jìn)行自定義后,不要忘記點(diǎn)擊屏幕頂部的保存按鈕。
That’s it, you’ve hidden the title on all your blog posts.
完成了!您已經(jīng)在所有博客文章中隱藏了標(biāo)題。
If you’d like a way to hide the title only on specific posts or pages, the next method should work for you.
如果您想要僅在特定的文章或頁面上隱藏標(biāo)題,下一種方法可能適合您。
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代碼來隱藏頁面或文章的標(biāo)題。這種方法只是從訪客的視野中隱藏標(biāo)題,但它仍然會(huì)在頁面的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.
這意味著搜索引擎仍然可以使用標(biāo)題來幫助它們理解您頁面的內(nèi)容,這對于您的WordPress網(wǎng)站的SEO非常有益,可以幫助您獲得更多的流量。
We’ll show you how to hide the title on specific posts or pages, or on all your posts and pages.
我們將向您展示如何在特定的文章或頁面上隱藏標(biāo)題,或者在所有文章和頁面上都隱藏標(biāo)題。
To hide a page or post’s title using CSS, you just need to know its ID.
要使用CSS隱藏頁面或文章的標(biāo)題,您只需要知道它的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儀表板中,要么轉(zhuǎn)到“文章” ? “所有文章”,要么轉(zhuǎn)到“頁面” ? “所有頁面”。然后找到您想要隱藏標(biāo)題的頁面或文章。
You can now open this post or page for editing.
您現(xiàn)在可以打開此文章或頁面進(jìn)行編輯。
Now simply take a look at the URL in your browser’s address bar.
現(xiàn)在只需查看瀏覽器地址欄中的URL。
You should see a ‘post=’ section followed by a number. For example ‘post=100.’
您應(yīng)該看到一個(gè)由數(shù)字跟隨的“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。請記下這個(gè)數(shù)字,因?yàn)槟鷮⒃贑SS代碼中使用它。
You can now go to Appearance ? Customize.
現(xiàn)在您可以轉(zhuǎn)到“外觀” ? “自定義”。
This launches the WordPress Customizer.
這將啟動(dòng)WordPress自定義器。
In the sidebar, simply click on Additional CSS.
在側(cè)邊欄中,只需單擊“附加CSS”。
Now scroll to the bottom of the sidebar.
現(xiàn)在滾動(dòng)到側(cè)邊欄底部。
You should now see a small text editor. This is where you’ll type your CSS code.
您現(xiàn)在應(yīng)該看到一個(gè)小型文本編輯器。這是您輸入CSS代碼的地方。
If you want to hide the title for a post, you’ll need to use the following code.
如果您想隱藏文章的標(biāo)題,您需要使用以下代碼。
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.
如果您想隱藏頁面的標(biāo)題,您需要使用略有不同的代碼。
Once again make sure you replace the ‘100’ with your real page ID.
如果您想隱藏頁面的標(biāo)題,您需要使用略有不同的代碼。
.page-id-100 .entry-title {
display: none;
}
Next, just scroll to the top of the page.
接下來,將頁面滾動(dòng)到頂部。
You can then click on the blue Publish button.
然后,您可以點(diǎn)擊藍(lán)色的“發(fā)布”按鈕。
Now if you check this page or post, the title should have disappeared.
現(xiàn)在,如果您檢查此頁面或文章,標(biāo)題應(yīng)該已經(jīng)消失了。
Is the title still there?
標(biāo)題還在嗎?
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中顯示的數(shù)字不同。
To get the correct ID, you’ll need to use your browser’s developer console.
要獲取正確的ID,您需要使用瀏覽器的開發(fā)者控制臺。
To start, head over to the page or post on your WordPress website. You can then open your browser’s developer console.
首先,轉(zhuǎn)到WordPress網(wǎng)站上的頁面或文章。然后,您可以打開瀏覽器的開發(fā)者控制臺。
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.
這一步驟會(huì)根據(jù)您使用的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+點(diǎn)擊,然后選擇”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.
如果您不知道如何打開開發(fā)者控制臺,您可以隨時(shí)查看瀏覽器的網(wǎng)站或官方文檔以獲取更多信息。
In the developer console, click on the three dotted icon. You can then select ‘Search.’
在開發(fā)者控制臺中,點(diǎn)擊三個(gè)點(diǎn)的圖標(biāo)。然后,您可以選擇“搜索”。
You should now see a search bar towards the bottom of the developer console.
現(xiàn)在,您應(yīng)該會(huì)在開發(fā)者控制臺的底部看到一個(gè)搜索欄。
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.
如果您正在查看一個(gè)WordPress頁面,您應(yīng)該會(huì)看到類似以下的內(nèi)容。
<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文章,控制臺應(yīng)該顯示類似以下內(nèi)容:
<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.
在這個(gè)示例中,"postid"的值為100。您現(xiàn)在可以將這個(gè)值與我們在上一步中提供的CSS代碼一起使用。
Simply add this code to your website using the WordPress Customizer, following the process described above.
只需按照上述描述的過程,使用WordPress自定義器將此代碼添加到您的網(wǎng)站上即可。
You can now take a look at the page or post. The title should have vanished.
您現(xiàn)在可以查看頁面或文章。標(biāo)題應(yīng)該已經(jīng)消失了。
To hide the titles for all your pages and posts, copy/paste the following into the text editor.
要隱藏所有頁面和帖子的標(biāo)題,請將以下內(nèi)容復(fù)制/粘貼到文本編輯器中。
.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.
您想要隱藏所有頁面的標(biāo)題,但不隱藏帖子的標(biāo)題嗎?為了隱藏所有頁面的標(biāo)題,請將以下內(nèi)容復(fù)制/粘貼到小文本編輯器中。
.page .entry-title {
display: none;
}
Another option is hiding the title for all of your posts. You can do this using the following CSS.
另一個(gè)選擇是隱藏所有帖子的標(biāo)題。您可以使用以下CSS代碼來實(shí)現(xiàn)。
.post .entry-title {
display: none;
}
Sometimes you may want to hide the titles for all your posts and pages.
有時(shí)候您可能希望隱藏所有頁面和帖子的標(biāo)題。
To do that, add the following.
要做到這一點(diǎn),請?zhí)砑右韵麓a。
.entry-title {
display: none;
}
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輕松地隱藏選擇性的頁面和帖子的標(biāo)題。這個(gè)免費(fèi)插件允許您隱藏任何頁面、帖子,甚至自定義帖子類型的標(biāo)題。
譯者注:請注意,隱藏標(biāo)題后,頁面或帖子的標(biāo)題將不再顯示在前臺,但標(biāo)題仍然存在于后臺編輯界面,您可以隨時(shí)修改和恢復(fù)標(biāo)題的顯示。
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插件安裝教程進(jìn)行操作。
Upon activation, open the page, post or custom post you want to edit.
在激活插件后,打開您想要編輯的頁面、帖子或自定義帖子。
Now simply scroll to the bottom of the right sidebar.
現(xiàn)在只需要向右邊欄的底部滾動(dòng)。
Here you’ll find a new ‘Hide Page and Post Title’ box.
在這里,您會(huì)找到一個(gè)名為“隱藏頁面和帖子標(biāo)題”的新框。
譯者注:請注意,這個(gè)框可能在編輯頁面或帖子的不同位置,具體取決于您的主題或其他插件的設(shè)置。通常,您可以在編輯頁面或帖子的右側(cè)邊欄或編輯器中找到該框。
To hide the title, just click to select the ‘Hide the title’ checkbox. You can then update or publish this post as normal.
要隱藏標(biāo)題,只需點(diǎn)擊選擇“隱藏標(biāo)題”復(fù)選框。然后,您可以像正常編輯頁面或發(fā)布帖子一樣更新或發(fā)布。
That’s it! If you visit the page you’ll notice that the title has disappeared.
就是這樣!如果您訪問該頁面,您會(huì)注意到標(biāo)題已經(jīng)消失了。
At some point you may need to restore this page or post’s title.
在某些時(shí)候,您可能需要恢復(fù)該頁面或帖子的標(biāo)題。
This is easy. Just open the page or post for editing. Then click to deselect the same ‘Hide the title’ checkbox.
這很簡單。只需打開要編輯的頁面或帖子。然后點(diǎn)擊取消選擇相同的“隱藏標(biāo)題”復(fù)選框。
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.
不要忘記點(diǎn)擊屏幕頂部的“更新”按鈕。現(xiàn)在,如果您訪問此頁面,標(biāo)題應(yīng)該已經(jīng)重新出現(xiàn)。
Another option is to hide the title using a page builder plugin.
另一個(gè)選項(xiàng)是使用頁面構(gòu)建器插件隱藏標(biāo)題。
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頁面構(gòu)建器插件。您可以使用這個(gè)插件輕松創(chuàng)建自定義頁面,甚至創(chuàng)建自己的WordPress主題。
This means you can easily hide the title on a custom page design or your theme.
這意味著您可以輕松地在自定義頁面設(shè)計(jì)或您的主題中隱藏標(biāo)題。
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附帶了一個(gè)模板庫,其中包含150多個(gè)模板,您可以用作頁面設(shè)計(jì)的起點(diǎn)。讓我們看看如何從其中一個(gè)主題模板中刪除標(biāo)題。
In your WordPress dashboard go to SeedProd ? Template Builder. You can then click on the Themes button.
在WordPress儀表板中,轉(zhuǎn)到SeedProd ? 模板構(gòu)建器。然后,您可以點(diǎn)擊主題按鈕。
This launches the SeedProd template library. You can now browse through all of the different designs.
這將啟動(dòng)SeedProd模板庫。您現(xiàn)在可以瀏覽所有不同的設(shè)計(jì)。
To take a closer look at a template simply hover your mouse over it. Then click on the magnifying glass icon.
要仔細(xì)查看模板,只需將鼠標(biāo)懸停在其上,然后點(diǎn)擊放大鏡圖標(biāo)。
This will open the template in a new tab.
這將在一個(gè)新標(biāo)簽中打開模板。
When you find a template that you want to use, hover your mouse over that template. Then simply click on the checkmark icon.
當(dāng)您找到一個(gè)要使用的模板時(shí),將鼠標(biāo)懸停在該模板上。然后只需點(diǎn)擊復(fù)選標(biāo)記圖標(biāo)即可。
This adds all of this template’s designs to your WordPress dashboard.
這將把這個(gè)模板的所有設(shè)計(jì)添加到您的WordPress儀表板中。
There are usually different designs for different types of content.
通常針對不同類型的內(nèi)容有不同的設(shè)計(jì)。
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.
您可以使用這些模板來隱藏不同內(nèi)容類型的標(biāo)題。例如,許多SeedProd模板都有一個(gè)專門的設(shè)計(jì)用于首頁。
To hide the title for your homepage, you would simply need to edit the Homepage template.
要隱藏首頁的標(biāo)題,您只需要編輯首頁模板即可。
To hide the title for all your posts, you’ll typically need to edit the Single Post template.
要隱藏所有文章的標(biāo)題,通常需要編輯Single Post模板。
Meanwhile if you want to hide the title from your pages you’ll usually edit SeedProd’s Single Page template.
而如果您想隱藏頁面的標(biāo)題,則通常需要編輯SeedProd的Single Page模板。
To edit a template hover your mouse over it.
要編輯模板,請將鼠標(biāo)懸停在模板上。
You can then go ahead and click on the Edit Design link.
然后,您可以點(diǎn)擊“編輯設(shè)計(jì)”鏈接進(jìn)行編輯。
This opens this design in the SeedProd drag and drop editor. To hide the title, find either the Post or Page Title.
這將在SeedProd的拖放編輯器中打開此設(shè)計(jì)。要隱藏標(biāo)題,請找到“文章標(biāo)題”或“頁面標(biāo)題”。
Once you spot this title, give it a click. SeedProd’s sidebar will now show all of the settings for the selected area.
一旦找到標(biāo)題,請點(diǎn)擊它。SeedProd的側(cè)邊欄將顯示所選區(qū)域的所有設(shè)置。
At the top of this panel you should see either Post Title or Page Title.
在這個(gè)面板的頂部,您應(yīng)該看到“文章標(biāo)題”或“頁面標(biāo)題”。
After confirming that you’ve selected the right area, hover over the Post Title or Page Title in the main SeedProd editor.
確認(rèn)選擇了正確的區(qū)域后,在主SeedProd編輯器中將鼠標(biāo)懸停在“文章標(biāo)題”或“頁面標(biāo)題”上。
You should now see a row of controls.
現(xiàn)在您應(yīng)該看到一行控件。
To remove the title from this design just click on the Trash icon.
要從此設(shè)計(jì)中刪除標(biāo)題,只需點(diǎn)擊垃圾桶圖標(biāo)。
SeedProd will ask whether you really want to delete the title. To go ahead and remove it, simply click on ‘Yes, delete it!’
SeedProd將詢問您是否真的要?jiǎng)h除標(biāo)題。要繼續(xù)刪除,請點(diǎn)擊“是,刪除它!”
The title will now disappear from your design.
標(biāo)題現(xiàn)在將從您的設(shè)計(jì)中消失。
To see how this will look on your website click on the Preview button.
要查看它在您的網(wǎng)站上的效果,請點(diǎn)擊“預(yù)覽”按鈕。
When you’re happy with your design click on the Publish button.
當(dāng)您對設(shè)計(jì)滿意時(shí),請點(diǎn)擊“發(fā)布”按鈕。
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.
根據(jù)您的網(wǎng)站設(shè)置,您可能需要從一些額外的模板中刪除標(biāo)題。例如,您可能希望隱藏所有文章和頁面的標(biāo)題。在這種情況下,您通常需要編輯單篇文章和單頁模板。
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.
如果您不確定,可以檢查一下組成您主題的所有設(shè)計(jì)。只需轉(zhuǎn)到SeedProd ? 主題構(gòu)建器。
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.
您現(xiàn)在應(yīng)該可以看到所有不同設(shè)計(jì)的列表。您現(xiàn)在可以按照上面描述的相同步驟編輯任何這些模板。
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.
在隱藏頁面或文章標(biāo)題之前,您應(yīng)該考慮一些影響,比如此操作對您的網(wǎng)站SEO的影響。
That being said, here are some of the most frequently asked questions about hiding the page and post title.
話雖如此,以下是關(guān)于隱藏頁面和文章標(biāo)題的一些常見問題:
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.
在隱藏標(biāo)題方面,似乎有一個(gè)簡單的解決方法。在創(chuàng)建頁面時(shí),只需將標(biāo)題字段留空即可。
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將在沒有標(biāo)題的情況下向訪問者顯示此頁面或文章。然而,確實(shí)存在一些問題。
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)”(無標(biāo)題)。這使得跟蹤頁面變得更加困難。
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?
如果您創(chuàng)建了許多不同的“(no title)”文章,那么您如何知道哪個(gè)是您的聯(lián)系我們頁面?哪個(gè)是您的首頁?
WordPress also uses the title to create the page’s URL.
WordPress還使用標(biāo)題來創(chuàng)建頁面的URL。
If you don’t provide a title, then by default WordPress uses a number instead, such as ‘www.mywebsite/8.’
如果您不提供,WordPress默認(rèn)使用一個(gè)數(shù)字,“wwwwebsite/8”。
Visitors often use the URL to help them understand where they are on your WordPress website, so ‘www.mywebsite/8’ isn’t particularly helpful.
訪問者通常使用URL來幫助他們理解自己在WordPress網(wǎng)站上的位置,“www.mywebsite/8”并不特別有幫助。
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不是一個(gè)友好的SEO永久鏈接,所以搜索引擎可能很難理解您的內(nèi)容是關(guān)于什么,并將其包含在相關(guān)的搜索結(jié)果中。
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.
如果您希望隱藏頁面或文章的標(biāo)題,您需要額外花費(fèi)一些時(shí)間來優(yōu)化您的WordPress SEO,包括設(shè)置SEO標(biāo)題。這樣可以確保搜索引擎即使沒有標(biāo)題也能理解頁面的內(nèi)容。
Here you’ll need a good SEO plugin, since WordPress doesn’t let you do this by default.
在這里,您將需要一個(gè)好的SEO插件,因?yàn)閃ordPress默認(rèn)情況下不允許您這樣做。
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插件。這個(gè)適合初學(xué)者的SEO工具包被超過300萬個(gè)網(wǎng)站使用。
If you need help getting started, then please refer to our guide on how to properly set up All in One SEO in WordPress.
如果您需要幫助入門,請參考我們的指南,了解如何正確設(shè)置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.
為了確保您的標(biāo)題被優(yōu)化,您可以參考我們的指南,了解如何使用AIOSEO中的標(biāo)題分析器。
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.
我們希望本文能幫助您學(xué)習(xí)如何隱藏選擇性WordPress文章和頁面的標(biāo)題。您還可以閱讀我們的指南,了解如何選擇最佳的網(wǎng)頁設(shè)計(jì)軟件和最佳的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上找到我們。
*請認(rèn)真填寫需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。