[WordPress] 外掛分享: Get Custom Field Values

WordPress 外掛 Get Custom Field Values 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Get Custom Field Values」是 2004-12-20 上架。
  • 目前有 2000 個安裝啟用數。
  • 上一次更新是 2023-10-10,距離現在已有 577 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.6 以上版本才可以安裝。
  • 有 4 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

coffee2code |

外掛標籤

meta | widget | widgets | shortcode | custom fields |

內容簡介

這個外掛提供一個強大的小工具、簡碼(包括簡碼建構工具)和模板標籤,方便檢索和顯示文章或頁面的自訂欄位值。

自訂欄位的威力讓這個外掛具有成為數十個外掛的潛力。

這個外掛讓您利用自訂欄位/元數據的威力。使用「取得自訂欄位」小工具、[custom_field] 簡碼(具有文章編輯器側邊欄小工具,協助您建立簡碼)或其中六個模板標籤之一,取得和顯示自訂欄位。找尋現有文章的自訂欄位、指定文章的自訂欄位、最近的文章的自訂欄位,或隨機選取自訂欄位中的值。對於外掛發現的自訂欄位值,您可以選擇性地指定要在結果之前和之後顯示的文字或 HTML。如果找不到任何結果,則不顯示任何內容(除非您定義搜索不到時顯示的文字)。如果有多個結果,只顯示第一個,除非您指定用於連接所有結果的字串(例如「,」)。請訪問「範例」部分了解如何多種方式使用這個外掛程式。

此外掛提供六個模板標籤。這裡是它們,以及它們使用的解釋:

- c2c_get_custom():在「迴圈」內使用這個為文章檢索自訂欄位值的模板標籤。
- c2c_get_current_custom():僅在永久網址文章模板(single.php)和頁面模板(page.php)上可用。可以在「迴圈」內或「迴圈」之外使用。可用於使用自訂欄位來定義您想要包含在文章或頁面標題、頁角或側邊欄中的文字。
- c2c_get_post_custom():當您知道您要取得自訂欄位值的文章 ID 時,這很有用。
- c2c_get_random_custom():隨機查找指定自訂欄位鍵的實例中的值,只要該欄位與已發佈的文章、非密碼保護的文章相關聯即可(您可以在外掛檔案中修改設定以搜索加密文章)。
- c2c_get_random_post_custom():當您知道您有興趣的文章的 ID 時,從文章中檢索隨機的自訂欄位值。
- c2c_get_recent_custom():從指定的自訂欄位中檢索最近(根據關聯文章的發布日期)的值。

您可以過濾外掛會顯示的自訂欄位值。為「the_meta」添加過濾器以過濾自訂欄位數據(請參閱代碼文件末尾的已註釋樣本)。您也可以通過鉤取「the_meta_$sanitized_field」添加每個自訂欄位的過濾器。$sanitized_field 是 $field 值的乾淨版本,其中除了字母和底線字符之外的所有內容都被刪除。因此,要篩選「相關文章」自訂欄位的值,您需要為「the_meta_RelatedPosts」添加過濾器。

鏈接:外掛首頁 | 外掛目錄 | GitHub | 作者首頁

開發者文檔

開發者文檔位於 DEVELOPER-DOCS.md。該文件涵蓋了數條模板標籤、鉤子和簡分的說明。

原文外掛簡介

This plugin provides a powerful widget, shortcode (with shortcode builder tool), and template tags for easily retrieving and displaying custom field values for posts or pages.
The power of custom fields gives this plugin the potential to be dozens of plugins all rolled into one.
This plugin allows you to harness the power of custom fields/meta data. Use the “Get Custom Field” widget, the [custom_field] shortcode (which has a post editor sidebar widget to help you build the shortcode), or one of six template tags to retrieve and display custom fields. Find a custom field for the current post, a specified post, a recent post, or randomly. And for the custom field values found by the plugin, you may optionally specify text or HTML to appear before and after the results. If nothing is found, then nothing is display (unless you define text to appear when no results are found). If multiple results are found, only the first will be displayed unless you specify a string to be used to join the results together (such as “,”), in which case all will be returned. Visit the Examples section to see how this plugin can be cast in dozens of different ways.
There are six template tags provided by this plugin. Here they are, with an explanation of when they are appropriate for use:

c2c_get_custom() : Use this inside “the loop” to retrieve a custom field value for a post
c2c_get_current_custom() : This is only available on the permalink post template (single.php) and page template (page.php). Can be used inside or outside “the loop”. Useful for using custom field to define text you want to include on a post or page’s header, footer, or sidebar.
c2c_get_post_custom() : Useful when you know the ID of the post whose custom field value you want.
c2c_get_random_custom() : Retrieve the value of a random instance of the specified custom field key, as long as the field is associated with a published posted, non-passworded post (you can modify a setting in the plugin file to search passworded posts as well).
c2c_get_random_post_custom() : Retrieves the value of random custom field(s) from a post when you know the ID of the post you’re interested in.
c2c_get_recent_custom() : Retrieves the most recent (according to the associated post’s publish date) value of the specified custom field.

You can filter the custom field values that the plugin would display. Add filters for ‘the_meta‘ to filter custom field data (see the end of the code file for commented out samples you may wish to include). You can also add per-meta filters by hooking ‘the_meta_$sanitized_field‘. $sanitized_field is a clean version of the value of $field where everything but alphanumeric and underscore characters have been removed. So to filter the value of the “Related Posts” custom field, you would need to add a filter for ‘the_meta_RelatedPosts‘.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer Documentation
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the numerous template tags, hooks, and shortcode provided by the plugin.
As an overview, these are the template tags provided the plugin:

c2c_get_custom() : Template tag for use inside “the loop” and applies to the currently listed post.
c2c_get_current_custom() : Template tag for use on permalink (aka single) page templates for posts and pages.
c2c_get_post_custom() : Template tag for use when you know the ID of the post you’re interested in.
c2c_get_random_custom() : Template tag for use to retrieve a random custom field value.
c2c_get_random_post_custom() : Template tag for use to retrieve random custom field value(s) from a post when you know the ID of the post you’re interested in.
c2c_get_recent_custom() : Template tag for use outside “the loop” and applies for custom fields regardless of post.

These are the hooks provided by the plugin:

c2c_get_custom_field_values_shortcode : Filter to customize the name of the plugin’s shortcode.
c2c_get_custom_field_values_post_types : Filter to customize the post types that should support the shortcode builder metabox.
get_custom_field_values/can_author_use_shortcodes : Filter to customize if post author can make use of the ‘custom_field’ shortcode.
get_custom_field_values/show_metabox : Filter to customize if the shortcode builder metabox is shown.

The shortcode provided is [custom-field], which has a number of attributes to customize its behavior and output.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Get Custom Field Values」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


2.1 | 2.5 | 3.0 | 3.2 | 3.3 | 3.5 | 3.6 | 3.7 | 3.8 | 3.9 | 4.0 | 4.1 | 3.0.1 | 3.3.1 | 3.3.2 | 3.6.1 | 3.9.1 | 3.9.2 | 3.9.3 | 3.9.4 | 4.0.1 | trunk |

延伸相關外掛(你可能也想知道)

  • Advanced Custom Fields (ACF®) 》Advanced Custom Fields 可以讓 WordPress 網站成為一個完整的內容管理系統,提供您所有工具以更好管理您的數據。, 使用 Advanced Custom Fields 外掛,完全...。
  • Facebook for WooCommerce 》這是官方版的「Facebook for WooCommerce」外掛,可將你的 WooCommerce 網站與 Facebook 連接。藉由此外掛,你可以安裝 Facebook 的像素碼、上傳你的線上商店...。
  • Meta pixel for WordPress 》這個外掛會為你的網頁安裝一個 Meta Pixel,這樣你就可以捕捉使用者與你的網頁溝通互動時所執行的動作,例如:產生潛在客戶、檢視內容、加入購物車、開始結帳...。
  • SEO SIMPLE PACK 》“SEO SIMPLE PACK”是一款非常簡單的SEO外掛程式。, , 輸出基本的meta標籤,是SEO措施所必需的。, 可以對每個頁面類型進行設置。, 您也可以設置SN...。
  • Quick Page/Post Redirect Plugin 》目前版本為 5.2.3, 這個外掛有兩個重定向功能 - "快速重定向" 和 "個別重定向":, 快速重定向 (301 重定向), 快速重定向被設計為快速而簡單的加入。你不需要設...。
  • Meta Tag Manager 》Meta Tag Manager 3.0 在 2.0 的巨大成功基礎上進一步發揮了作用,也標誌著我們的新專業版附加元件的推出。自 2009 年以來,我們一直提供免費的、定期維護的...。
  • Advanced Custom Fields: Extended 》🚀 全方位增強套件,可改進WordPress和Advanced Custom Fields。此外掛旨在提供一個強大的管理框架,涵蓋了眾多改進和優化。, 此外掛需要至少 ACF Pro 5.8。,...。
  • Smart Custom Fields 》Smart Custom Fields 是一個管理自訂欄位的簡單外掛。, 功能, , 支援自訂欄位群組迴圈。, 支援元資料修訂。, 支援元資料預覽。, , , 欄位類型, , 文字, 文字...。
  • Custom Field Template 》「Custom Field Template 外掛」在「編寫文章/頁面」時,新增自訂欄位的預設設定。這個模板格式基本上跟「rc:custom_field_gui 外掛」差不多,不同處在於:, ...。
  • Title and Nofollow For Links (Classic Editor) 》這個外掛程式在插入連結彈出框中恢復了 WordPress 4.2 中刪除的「Title」欄位,並新增了一個「將連結加上 rel="nofollow"」的勾選框。, Gutengerg(區塊編輯...。
  • Simple Taxonomy Ordering 》使用這個簡單易用且直觀的拖放介面,將您網站上所有的分類體系排序安排。這個外掛適用於 WordPress 核心的分類體系,包括「分類」和「標籤」,以及您所創建的...。
  • Custom Block Builder – Lazy Blocks 》WordPress 自訂區塊外掛程式, ★★★★★, 開發商使用於 WordPress 自訂區塊的魔法棒。我們創建了 Lazy Blocks WordPress 外掛程式,協助每位開發商取得他們需要的...。
  • Secure Custom Fields 》總結:SCF 是一款能夠擴展 WordPress 功能的外掛,使其成為一個靈活的內容管理工具。透過 SCF,管理自定義數據變得簡單高效。, , 1. 為什麼 SCF 是一個靈活的...。
  • WP REST API Controller 》WP REST API Controller 外掛提供使用者易用的圖形化介面,使管理員可以切換 WordPress 核心和自訂文章類型以及分類法的可見性和端點,同時也可以自訂 API 回...。
  • WP Meta SEO 》WP Meta SEO 讓您掌控所有 SEO 優化。批次處理 SEO 內容和圖片 SEO,內頁內容檢查、404 和重定向, WP Meta SEO 外掛,主要的搜尋引擎優化功能, , 在單一檢視...。

文章
Filter
Apply Filters
Mastodon