[WordPress] 外掛分享: All Post Type Ajax Search

首頁 › 外掛目錄 › All Post Type Ajax Search
WordPress 外掛 All Post Type Ajax Search 的封面圖片
全新外掛
安裝啟用
—
尚無評分
25 天前
最後更新
—
問題解決
WordPress 5.0+ PHP 7.2+ v1.1.0 上架:2025-09-15

內容簡介

### 總結:
All Post Type Ajax Search 是一款輕量且安全的搜尋外掛,能即時以 AJAX 技術返回搜尋結果。使用者可以透過設定畫面精確選擇要包含在搜尋中的各種內容類型(文章、頁面、產品等)。每個搜尋結果都包含縮圖(或預設圖片)、標題和連結。

### 問題與答案:
1. **這個外掛的主要優勢是什麼?
- 迅速的前端搜尋功能,顯示最多 5 個結果,搜尋字元至少要 3 個以上。
- 管理員擁有完整控制權:可以選擇要顯示的文章類型。
- 智慧篩選以避免顯示技術性類型(附件、修訂、訂單、變體等)。
- 採用安全最佳實踐:使用 nonces、消毒和跳脫功能。
- 採用程序性簡單代碼,適用於各級開發人員自定義。
- 已準備好進行翻譯(textdomain: all-post-type-ajax-search)。

2. **這個外掛的一些特色有哪些?
- 簡單的短碼:[all-post-type-ajax-search]。
- 在管理後台進行設置:選擇啟用的文章類型和設置預設圖片(URL)。
- 每個項目的結果:包含縮圖(或預設圖片)、標題和連結。
- 搜尋邏輯將結果分佈在不同文章類型中,不會始終優先顯示 ‘post’ 或 ‘page’。
- 預設限制:5 個結果;最少 3 個字符開始搜尋。
- 效能優化:在查詢中使用 no_found_rows,限制每個查詢的文章數量。
- 安全性:在 AJAX 和設置中使用 nonces;管理員中進行能力檢查(manage_options)。
- 可以透過過濾器和操作輕鬆擴充(例如 apply_filters( ‘aptas_default_image’, … ))。

3. **開發者的附加註釋有哪些?
- 已保存選項:
- aptas_search_post_types(陣列):啟用的文章類型。
- aptas_default_image_url(字串):預設圖片的 URL。
- Nonces:
- AJAX:aptas_search_nonce
- 管理員:aptas_settings_save(名稱 aptas_settings_nonce)
- 短碼:[all-post-type-ajax-search]
- 有用的過濾器:
- aptas_default_image — 允許透過程式碼替換預設圖片。
- 鉤子:
- aptas_ajax_search(ajax 事件) — 使用 wp_ajax_aptas_ajax_search / wp_ajax_nopriv_aptas_ajax_search。

4. **這個外掛是否支持捐款?
- 是的,如果你覺得這個外掛對你有幫助並且喜歡我的工作,你可以邀請我喝咖啡作為捐贈支持。非常感謝你的支持! ☕️

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「All Post Type Ajax Search」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

All Post Type Ajax Search adds a lightweight, secure search box that returns results in real time (AJAX). From the settings screen you choose exactly which content types (posts, pages, products and other custom post types) are included in the search. Each result shows a thumbnail (or a default image), the title and a link.
Main advantages:

Fast front-end search with up to 5 results and a minimum of 3 characters.
Full control from the admin: choose the post types that appear in the results.
Smart filtering that hides technical types (attachments, revisions, orders, variations, etc.).
Built following WordPress security best practices: nonces, sanitization and escaping.
Simple procedural code, easy to customize for developers of any level.
Translation ready (text domain: all-post-type-ajax-search).

Features

Simple shortcode: [all-post-type-ajax-search].
Admin settings: choose the enabled post types and set a default image (URL).
Each result shows a thumbnail (or the default image), the title and a link.
Results are spread across post types so posts or pages are not always shown first.
Default limit of 5 results; searching starts at 3 characters.
Performance: no_found_rows in queries, limited posts per query, and CSS/JS loaded only on pages that contain the shortcode.
Security: nonces for AJAX and settings; capability checks (manage_options) in the admin.

Video

Additional Notes for Developers

Stored options:

aptas_search_post_types (array): enabled post types.
aptas_default_image_url (string): default image URL.

Nonces:

AJAX: aptas_search_nonce
Admin: aptas_settings_save (field name aptas_settings_nonce)

Shortcode: [all-post-type-ajax-search]
AJAX action: aptas_ajax_search (wp_ajax_aptas_ajax_search / wp_ajax_nopriv_aptas_ajax_search).

延伸相關外掛

文章
Filter
Mastodon