
內容簡介
開發 Hello 佈景主題的開發人員們,您好!
您是否曾經想要為一篇文章新增多個特色圖片呢?現在透過「Featured Galleries」外掛,您就可以這麼做了!這個外掛和 WordPress 的 Featured Images 功能類似,唯一的不同是文章會有整個圖庫而非只有單一圖片。這些圖庫幾乎和 Featured Images 相同,利用了 WordPress 內建的媒體管理器。使用者可以透過簡單的拖放介面選擇圖片、定義順序和儲存圖庫。
註:此外掛不處理前端 HTML 建立,這留給佈景主題處理以允許最大彈性。Featured Galleries 只處理後端/管理面板介面建立特色圖庫並把它們存為 Metadata。您需要將其整合到您的佈景主題中,或使用內建整合功能的佈景主題。
快速入門整合到佈景主題
有關更多資訊,請參閱GitHub Wiki。
我試著將這個框架做成盡可能直觀的方式。佈景主題可以按照加入 Featured Images 的方式將 Featured Galleries 加入其中。在任何模板檔案中,佈景主題將呼叫get_post_gallery_ids() 函式以顯示該圖庫。只要在迴圈中使用,此函式不需要任何參數,預設會返回一個包含圖片 ID 的陣列。
範例
在迴圈中設置。這會以陣列形式返回 Featured Gallery 中的所有圖片,然後使用 HTML <img> 標籤來迴圈顯示每個圖片。
$galleryArray = get_post_gallery_ids();
foreach ( $galleryArray as $id ) {
echo '<img src="' . wp_get_attachment_url( $id ) .'">';
}
您也可以自訂從函式中返回的值以符合您的需求。請參閱函式文件的完整頁面以取得詳細資訊。
自訂文章類型
此外掛附帶一個篩選器,以便輕鬆地將 Featured Galleries 加入自訂文章類型中。詳細資訊請參閱fg_post_types 的文件頁面。
自訂媒體管理器
媒體管理器可以以多種方式進行自訂,詳細資訊請參閱fg_show_sidebar 和 fg_use_legacy_selection 篩選器文件頁面。
想要幫忙嗎?
我非常歡迎您協助國際化本外掛。曾經是可以運作的,但現在則需要重新呈現,因為我不太了解它的運作原理。
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Hello Theme Developers!
Have you ever added a Featured Image to a post and thought to yourself, “I wish I could add more than one image this way”? Well, now you can. Featured Galleries mirrors the Featured Images functionality of WordPress. The only difference is that posts get an entire gallery rather than just a single image. These galleries behave almost exactly like Featured Images, and make use of WordPress’s built in Media Manager. Users can select images, define the order, and save the gallery, all through a simple drag-n-drop interface.
Note: This plugin DOES NOT HANDLE THE FRONTEND HTML CREATION. That is left for themes to handle, to allow for maximum flexibility. Featured Galleries just handles the backend/admin interface for creating featured galleries and storing them as metadata. You will need to integrate this into your theme, or use a theme with prebuilt integration.
Quick Start Guide to Integrate Into Themes
For more information, see GitHub Wiki.
I’ve tried to make this as intuitive as possible. Themes can integrate Featured Galleries in the same way they integrate Featured Images. Inside any template file where the gallery should appear, the theme will call the get_post_gallery_ids() function. As long as it is used inside the loop, the function doesn’t need any parameters. By default, it will return an array of image IDs.
Example
Set inside the Loop. This returns all images in the Featured Gallery, as an array, then loops through to display each using an HTML tag.
$galleryArray = get_post_gallery_ids();
foreach ( $galleryArray as $id ) {
echo '';
}
You can also customize the returned value from the function to suit your needs. See the full function documentation page for details.
Custom Post Types
The plugin comes with a filter to easily add Featured Galleries to custom post types. See the fg_post_types documentation page for details.
Customizing the Media Manager
The media manager can be customized in sevearl ways. See the fg_show_sidebar and fg_use_legacy_selection filter documentation pages for details.
Want to Help?
I’d love some help with internationalization. It was working at one point, but drivingralle did that code because I don’t really understand it, and I’m not sure it’s still working.
