
內容簡介
設置您的文章的主要類別... 然後對其進行操作。
為什麼我要(primary category)主要類別?
當您在 WordPress 上發布文章時,通常會給予文章多個類別。如果您的網站沒有限定每篇文章只能有一個類別,當 WordPress 自動選擇代表文章的類別時,這可能會造成顯示上的問題,因為您很可能需要選擇一個重要的主要類別,而不是 WordPress 自動為您選擇的類別。
例如,您的博客主題是有關動物的,您發布了一篇名為「為什麼狗愛水而貓卻討厭水?」的文章,並將類別分配為「貓咪」、「狗狗」和「寵物」。
預設情況下,WordPress 可能會顯示「貓咪」作為文章的代表類別,但是既然這篇文章相同地涵蓋了貓和狗,那麼「寵物」可能更適合作為主要類別。
這個外掛允許您有效地解決此類問題,不管是為了顯示、結構、組織、SEO,還是所有前述目的。
主要類別(primary category)有什麼用途?
[primary-cat]
您可根據自己的需要進行創意運用,這裡是一些我想到的例子:
您可以在文章標題上方呈現文章所屬的主要類別(透過在您的主題代碼、子主題或自訂功能外掛中加入 <?php echo do_shortcode( '[primary-cat]' ); ?>,這樣可以以某種美觀的方式樣式化,例如使用CSS .primary-cat)。 許多博客、新聞和雜誌網站都使用這個功能。
如果您使用自訂 /%category%/%postname%/ 永久連結結構,可以讓文章網址中顯示適當的slug。
在您的網站上使用面包屑導航(透過使用shortcode [primary-bread]),這樣有助於提高用戶體驗 (可以使用CSS #breadcrumbs進行樣式設定),並在某種程度上提高 SEO。
外掛標籤
開發者團隊
原文外掛簡介
💬 Ask Question | 📧 Email Me
Set a primary category for your posts… and then do stuff with it.
Why would I want a primary category?
Out of the box, WordPress allows you to assign multiple categories to a post. Unless you’re enforcing a strict one-category-per-post-only rule for your website, this can be a problem now for displaying the most important category for your respective posts, as opposed to WordPress automatically selecting it for you.
Let’s say that your blog is about animals, and you publish an article titled “Why Do Dogs Love Water and Cats Hate It?” with the categories: Cats, Dogs, and Pets assigned to it.
By default, anywhere that WordPress might display a single category to represent the post, it’s probably going to display Cats by default, but since the post is equally about both cats and dogs, maybe the more general Pets category would be more appropriate.
This plugin allows you to accomplish that, whether it’s for presentational, structural, organizational, SEO, or all of the above purposes.
In what ways can I utilize a primary category?
[primary-cat]
In any creative way that you can imagine, but here are some examples I thought of:
To present the main category that the post belongs to above its title (by adding in your theme code, child theme, or custom functions plugin), in some aesthetic way (which can be styled with CSS .primary-cat). Lots of blog, news, and magazine sites have this feature.
To have the appropriate slug in your post URLs if you’re using the custom /%category%/%postname%/ permalink structure under Settings > Permalinks.
To have breadcrumbs (by using the shortcode [primary-bread]) on your site for user-friendliness (which can be styled with CSS #breadcrumbs), and can in turn, also improve SEO.
