2022-10-14

如何使用 Oxygen Builder conditions 控制內容隱藏或顯示

Conditions 讓內容控制更靈活

今天在優化個人網站,想要 Logo 在首頁不顯示,但在其他內頁要看到。所以必須要有個機制來判斷訪客現在看到的頁面是否為首頁?用 Oxygen 內建的條件式判斷 (Conditions control) 非常容易做到,以下示範

只在首頁顯示社群網站連結,其他都不要。設定方式如下:

選擇目標物件: Social Icons
Oxygen Conditions control
設定條件,點擊 Set Conditions
Oxygen Conditions control
選擇 Dynamic Data -> php function return value,使用 wordpress 內建功能 is_front_page 判斷是否為首頁,選擇 is_not_blank,不要隱藏社群 icons,反之,要在首頁隱藏,就選 is_blank
Oxygen Conditions control
Oxygen Conditions control
Oxygen Conditions control
Determines whether the query is for the front page of the site
Oxygen Conditions control
選擇 is_not_blank,不要隱藏社群 icons,反之,要在首頁隱藏,就選 is_blank

儲存設定,完成。

Oxygen Conditions control
首頁導覽列有 Social icons
Oxygen Conditions control
其他內頁沒有

影片教學

其他 Oxygen 教學:如何在 Oxygen Builder 設定水平滑動導覽列(Horizontal Scroll Menu)

參考來源:Using Oxygen's Conditions to hide an element on your WordPress homepage

請我喝杯咖啡吧 ^^
No active "bsf-sb-post-end" sidebar

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

PeiYing Tsai
author
愛藝術,喜歡以科技解決問題的數位產品設計師。 堅持信念,任何困難事,必有搞定的一天,Just try it! 隨手紀錄日常學習到的知識心得,希望對妳/你有幫助。
coffee-cup linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram