![](/img/trans.png)
[英]Any easy way to determine whether functions work on reference or call by value?
[英]Any way to get two functions to work on the same request?
我正在嘗試刪除函數中帖子和頁面上的 Yoast 架構。php。 但是,一個人會工作,但在一起他們不會。 有什么辦法讓它一起工作嗎?
到目前為止,這是我嘗試過的:
//Remove All Schema on post
add_filter( 'wpseo_json_ld_output', 'yoast_seo_json_remove_partial_post' );
function yoast_seo_json_remove_partial_post() {
if ( is_single ( [ 2544, 2743 ] ) ) {
return false;
}
}
//Remove Schema on Page
add_filter( 'wpseo_json_ld_output', 'yoast_seo_json_remove_partial_page' );
function yoast_seo_json_remove_partial_page () {
if ( is_page ( [ 15, ] ) ) {
return false;
}
}
如果可能,我需要從我想要的任何頁面中刪除它們。 感謝您對此的任何幫助。
您可以只使用 OR 運算符作為條件
add_filter( 'wpseo_json_ld_output', function( $default ) {
if ( is_single ( [ 2544, 2743 ] ) || is_page ( 15 ) )
return false;
return $default;
});
請從下面的代碼中刪除,。 它可能會終止代碼
if ( is_page ( [ 15, ] ) ) {
return false;
}
}
或者,請創建一個函數並使用邏輯 OR 運算符組合兩個條件,而不是使用兩個函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.