我一直在嘗試使用is_ios()函數,但它似乎並沒有工作。一旦頁面編譯完成後,我使用is_ios()將我的php代碼放到了空白處。WordPress的:is_ios()函數不工作
這是Wordpress文檔的頁腳部分。
<?php if (is_ios()) : ?>
<a href="instagram://user?username=USERNAME">
<?php else : ?>
<a href="http://www.instagram.com/USERNAME">
<?php endif; ?>
<i class="fa fa-instagram fa-2x" aria-hidden="true"></i></a>
如果我改變<?php if (is_ios()) : ?>
到<?php if (wp_is_mobile()) : ?>
代碼將運行正常。
我不確定是否需要包含任何內容。在查看文檔(https://developer.wordpress.org/reference/classes/wp_customize_manager/is_ios/)後,我檢查了該函數是否存在於正確的位置,並確實存在。我不知道還有什麼要嘗試。任何見解或幫助將不勝感激。
全碼
<?php
/**
* The template for displaying the footer
*
* Contains the closing of the #content div and all content after
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
?>
<footer class="footer text-center">
<div class="container">
<p><strong>
<i class="fa fa-copyright" aria-hidden="true"></i> USERNAME
</strong> <a href="#"><i class="fa fa-facebook-square fa-2x" aria-hidden="true"></i></a>
<a href="https://twitter.com/USERNAME"><i class="fa fa-twitter-square fa-2x" aria-hidden="true"></i></a>
<?php if (is_ios()) : ?>
<a href="instagram://user?username=USERNAME">
<?php else : ?>
<a href="http://www.instagram.com/USERNAME">
<?php endif; ?>
<i class="fa fa-instagram fa-2x" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-envelope fa-2x" aria-hidden="true"></i></a>
</p>
</div>
</footer>
<?php wp_footer(); ?>
</body>
</html>
檢查日誌錯誤的詳細信息(或打開錯誤報告)。從你鏈接的文檔看,它看起來像是類「WP_Customize_Manager :: is_ios()」的一部分,所以你沒有正確調用它。 – ceejayoz
@ceejayoz打開錯誤報告(很酷的東西),並簽出堆棧跟蹤。 '致命錯誤:未捕獲錯誤:調用未定義的函數is_ios()''所以我試圖改變函數內部的is_ios()''WP_Customize_Manager :: is_ios()'並得到一個新的錯誤'致命錯誤:未捕獲錯誤:類'找不到WP_Customize_Manager'。所以我覺得我需要以某種方式導入這個類? –