內容簡介
如果您知道 Style Sheet 是什麼,並了解 SEO 規則,那麼您應該知道最安全的方式是按照 slug(縮略名)為每個菜單項目添加圖標,或對於每個頁面/文章列表項目應用不同的圖像/圖形/圖標,因為它是唯一永遠不會更改的,否則搜索引擎會失去您的頁面索引和價值。
以下是一些有助於主題開發的提示:
這不能通過 WP 提供的模板標籤來實現。
菜單項目 ID#將不會獲得實際文章 ID#
菜單項目標題為空,除非您手動更改其名稱。
由於移動、重新導入和其他內容處理,頁面/文章 ID 可能會更改,從而破壞您的樣式表。
從 WP2.9 開始,可以使用類名,但它們需要手動添加。
菜單需要啟用並更改主題才能使它們運作。
新的博客不會從您的主題中提取這些菜單類。
在當前的 WordPress 版本中,有一個限制會從菜單項目的數據庫中移除文章標題和文章名稱,以防止它們與實際頁面混淆。 是的,它們存儲在同一個表中,直到所有功能都被修訂為安全,不會混淆導航菜單項目和文章或頁面,您不能獲取名稱、標題或 URL!不使用單個 WP 模板標籤。
盡管 WP 認為文章的 ID 是您可以用來引用文章的更安全和恒定的數據,但這僅適用於您的 WP 安裝內部,並不能擴展到現實世界。文章或菜單 ID 可能會因數據庫備份、域名更改、替換頁面、創建新菜單項目等多種因素而更改,但有一個您永遠不允許更改的東西,那就是永久鏈接(PERMALINK)。
更改文章的 URL 的後果非常嚴重,我們的最佳客戶就是那些把他們的網站交給一些充滿技巧的人承諾在搜索引擎上實現神奇排名的人,他們失去了 50% 的價值(對於依靠 2M 網路銷售的公司)。
文章和菜單 ID 可能會更改,從而破壞您的 Style Seet 規則,並失去自定義徽標。
您可能希望更願意支付開發人員的額外費用以使永久鏈接保持不變,而不是 ID。
因此,現在對於您來說最安全和恆定的數據是永久鏈接,而不是 ID。不管您的程序員說什麼更安全,您都應該盡一切努力以此方式完成,因為他為您的 Google 排名工作,而不是為 WordPress 工作,請聽我這裡的建議。
經過數天的掙扎,嘗試解決此問題,我意識到無人這樣做是因為 WordPress 並未提供相應的數據。
如果您是 WP 大師或像我這樣的代碼猴,請查閱有關此插件釋放代碼的文章,因為該代碼可以讓您破解無法獲取標題的 wp 類:
如果您不想破解 .php 文件,那麼這是一個待用的插件,很快就會出現在 WordPress 網站上。
它非常簡單,但它會向每個菜單/列表項目添加恰當的頁面/文章的 slug(縮略名),使您能夠以不同方式樣式它們,解決了 WP 不保存頁面名稱、標題或 URL 的限制問題。它還需要一點時間讓您的 SEO 定義正確的永久鏈接,您仍然需要在他的更改後重新調整樣式表 (在下一版中,此插件將跟踪更改),但是一旦永久鏈接被定義(它們應該在發布文章之前定義),您的圖標/樣式將與您的菜單項目保持在一起,無論上述場景您的 post ID 是否更改。
外掛標籤
開發者團隊
原文外掛簡介
If you know what a Style Sheet is and know that SEO rules, then you should know that the safest way to iconize a menu item or style each page/post list items with a different image/graphic/icon is by its slug, since it’s the only thing that you will ALWAYS keep the same, or search engines would lose your page’s index and value.
Some tips to save you the time with your theme development:
This can not be achieved with WP provided template tags.
Menu item ID# won’t get you the actual post ID#
Menu item title is EMPTY at least you name it differently by hand.
Page/Post ID could change by moving, re-importing and other content handling, breaking your style sheet.
A new blog won’t take those menu classes from your theme.
There’s a limitation on current wordpess version that removes post-title and post-name from menu-items in database, to prevent them to be confused with the actual page. Yes, they are stored in the same table, and until all the functions are revised to be safe not to confuse nav-menu-items with posts or pages, you can’t get the name nor title nor url! Not with single wp template tags.
Although WP considers the ID of the post as the more safe and CONSTANT piece of data you can use to refer your article as, but that’s inside your WP installation, not extensible to the real world. The post or menu ID could change due to several factors like backing up your site, moving domain, replacing page, new menu items created, etc., but there’s something you will NEVER allow to change: the PERMALINK.
Post and Menu IDs could change, breaking the link with your Style Seet rules, and losing your custom logos.
You might want to rather pay extra your developer to keep permalinks the same, than IDs.
So now the most SAFE and CONSTANT piece of data, for you, is the permalink, not the ID. You should do ANYTHING to get it done this way, regardless of what your programmer says is safer. He works for your Google rank, not for WordPress, so listen to me, not them.
After banging my head for days trying to get a solution for this, I realized nobody does it because WordPress doesn’t provide the data (yet).
If you are a WP guru, or a coder monkey like me, check the article about this plugin’s release for the code what will allow you to hack that wp class that can’t get the title:
If you wouldn’t hack your .php files, here’s a ready-to-use plugin, soon to appear in WordPress pages.
Features
Adds a pagenamed_name-of-your-page class to each menu / list item for you to style them different, working-around WP limitation on not saving page name or title or url of the related page in menu items DB rows.
Better than using IDs, since the permalink MUST stay FOREVER for Google indexing, while menu and page ID are important only inside WP database.
Adds a pagenamed_name-of-your-page class to each menu / list item for you to style them different.
Works for either custom menus or page listings made with the previous wp_list_pages() function.
Extra code to remove unwanted useless classes from menus (Need plugin editing)
Future features
It will keep track of changes made to permalink to update the stylesheet (even though is not recommended for an old page, to prevent losing indexed value in google)
Option in admin panel to remove unwanted useless classes from menus.
Don’t forget to rate it and tell it works! 〉〉〉〉〉〉〉〉〉〉〉〉
Instructions
Easy: Install and activate. No options yet (future releases will)
Check out PageNamed Menu Classes plugin page for bug reports, updates, help, and to find other interesting plugins.
