add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
$new_terms[] = $term;
}
$terms = $new_terms;
}
return $terms;
}
这段是现在的代码 我数据库里有一个表有一个字段是term_id 我已经把需要显示的分类的term_id存在了$duqu里面 我想问下 怎么把这个变量插到上面的代码里面可以只显示那些被选出来的term_id的分类呢 谢谢了
回复讨论(解决方案)
你给的代码根本找不到term_id与$duqu,怎么帮你改
一般想达到你的要求,传一个判断就可以了!
你给的代码根本找不到term_id与$duqu,怎么帮你改
一般想达到你的要求,传一个判断就可以了!
不好意思啊 有点忙 才回来看帖子
是这样的 那段代码是程序里自带的 我不太懂 后来那些term_id什么的 是我从数据库表里面自己导出来的 所以变量的名称设的可能不一样
我研究了一下 找到了一个解决方法 但是有一个地方弄不好麻烦你看下会不会 谢了
if ( ! in_array( $term->slug, array( ) ) ){
$new_terms[] = $term;
}
我用了这段程序实现让一部分分类不显示 比如说我不想显示slug值为A的分类 就写成array('A')就可以
但是我想不显示的有很多
$shaixuankuwp_terms=mysql_query("SELECT * FROM `wp_terms` where term_id='".$duqu_term_id."'");
这段我筛选出了表里所有我想不显示的行
while ($duqushujukuwp_terms=mysql_fetch_array($shaixuankuwp_terms)){ $duqu_slug=$duqushujukuwp_terms[slug]; }
这段我一行一行读出了分类的slug
但是我不知道该怎么把$duqu_slug 这个全部放到上面的array()里面 貌似array()里面不能放数组 只能一条条放
码放帮忙看看怎么改啦 谢谢啦
while ($duqushujukuwp_terms=mysql_fetch_array($shaixuankuwp_terms)){ $duqu_slug[]=$duqushujukuwp_terms[slug]; }
$duqu_slug就是你不想显示的行的数组。
while ($duqushujukuwp_terms=mysql_fetch_array($shaixuankuwp_terms)){ $duqu_slug[]=$duqushujukuwp_terms[slug]; }
$duqu_slug就是你不想显示的行的数组。
谢谢啦 虽然已经解决了

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
