From cb1ce2e878141f5d156bc58825325b851f1acf60 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 14 Mar 2023 19:47:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/theme/wp/components/widget/category.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/theme/wp/components/widget/category.go b/internal/theme/wp/components/widget/category.go index 5068bec..e57a06c 100644 --- a/internal/theme/wp/components/widget/category.go +++ b/internal/theme/wp/components/widget/category.go @@ -173,11 +173,14 @@ func parseDropdownCate(h *wp.Handle) (cateName string, r bool) { if cat == "" { return } - cates := slice.SimpleToMap(cache.CategoriesTags(h.C, constraints.Category), func(v models.TermsMy) uint64 { - return v.Terms.TermId + id := str.ToInteger[uint64](cat, 0) + if id < 1 { + return + } + i, cc := slice.SearchFirst(cache.CategoriesTags(h.C, constraints.Category), func(my models.TermsMy) bool { + return id == my.Terms.TermId }) - cc, r := cates[str.ToInteger[uint64](cat, 0)] - if !r { + if i < 0 { return } cateName = cc.Name