內容簡介
讓你的訪客避免不必要的 404 錯誤吧!
當訪客到達一個不存在的頁面時,不要輕易放棄,做出努力去猜測他們最初是在尋找什麼。這個外掛會使用請求的 URL 中的關鍵字搜尋你的文章、頁面、標籤和類別。如果有相符的內容,就會重新導向到該內容,而不是顯示錯誤頁面。如果有多個相符的內容,404 頁面將使用一些模板標籤為訪客提供建議列表。
請前往Smart 404 首頁瞭解更多資訊。
模板標籤
smart404_has_suggestions
如果有建議,返回 true;否則返回 false
smart404_get_suggestions
返回一個文章物件陣列,供手動呈現。
smart404_suggestions
顯示建議文章列表。
可以傳遞「list」參數以列表方式呈現建議。
smart404_loop
用於建立 Loop 的文章查詢。例如:
<?php smart404_loop(); ?>
<?php while (have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endwhile; ?>
請注意,該循環無法正確顯示頁面,因為它不支援頁面。如果使用像上面那樣的循環,建議不要啟用頁面搜尋。
smart404_get_search_terms
檢索用於填充建議列表的搜尋詞組陣列,以用於上下文加亮等。
如需支援和最新源代碼,請訪問 https://github.com/leonstafford/smart-404。
外掛標籤
開發者團隊
原文外掛簡介
Save your visitors from unhelpful 404 errors!
Instead of quickly giving up when a visitor reaches content that doesn’t exist, make an effort to guess what they were
after in the first place. This plugin will perform a search of your posts, pages, tags and categories, using keywords from the requested
URL. If there’s a match, redirect to that content instead of showing the error. If there’s more than one match, the
404 template can use some template tags to provide a list of suggestions to the visitor.
See the Smart 404 homepage for more information.
Template tags
smart404_has_suggestions
Returns true if there are some suggestions, false otherwise
smart404_get_suggestions
Retrieve an array of post objects for rendering manually.
smart404_suggestions
Draw a list of suggested posts.
Pass the parameter “list” to render suggestions as a list.
smart404_loop
Query posts for use in a Loop. Eg:
Note that the loop will not display pages correctly, as it is not built to support them. It is recommended that if you use
a loop like that above, do not enable searching of pages.
smart404_get_search_terms
Retrieve an array of search terms used to populate the suggestions list, for use with contextual highlighting, etc.
For support and latest source code, please visit https://github.com/leonstafford/smart-404
