解決 Avada 主題 5.3 更新到 WordPress 4.9 後,「頁面屬性」 框中缺少頁面模板的問題;

標籤: 

正在查看 4 個帖子:1-4 (共 4 個帖子)
  • 作者
    帖子
  • 詩語
    管理員
    • 文章數量: 5,925
    @feibisi
    樓主

    嘗試着編輯站點頁面,但是發現居然找不到頁面模板設置了,本身使用 Avada 主題會自帶的有一些內置的頁面模板,但是早上該內容找不到了。

        

    到官方找了下解決方案:

    WordPress 從 4.9 版本引入了一個緩存機制到主題中獲取文件列表。這也導致頁面編輯屏幕頁面屬性元框中的頁面模板緩存。當使用子主題時,更新到 WordPress 4.9 並將 Avada 更新到 5.3 後,某些用户從下拉列表中缺少頁面模板。

    一段時間後,問題將得到自動更正,當一個主題的文件緩存清除。不幸的是,無法立即清除它。整個問題目前被歸類為一個 WordPress 的核心問題,這裏跟蹤 https://core.trac.wordpress.org/ticket/42573,並希望在 WordPress 4.9.1 中解決。

    TEMPORARY SOLUTION:為了立即清除緩存,你可以在下面下載這個小插件,並通過 WP Dashboard> Plugins> Add New 進行安裝。點擊上傳插件按鈕,安裝完成後激活插件。插件名稱是:修復主題模板文件緩存 (WP Trac#42573) 。最後打開一個頁面編輯屏幕。現在所有頁面模板都應該可以再次使用。一旦情況如此,您可以再次卸載該插件。

    臨時解決辦法,插件下載:

    https://theme-fusion.com/wp-content/uploads/2017/11/fix-page-templates.zip

    詩語
    管理員
    • 文章數量: 5,925
    @feibisi
    樓主

    插件啓用後,什麼都不用管,只需要安裝會自動清除緩存,不需要了刪除即可。

     

    詩語
    管理員
    • 文章數量: 5,925
    @feibisi
    樓主

    插件代碼其實也比較簡單,就是一段 PHP 代碼段,不想裝插件的就直接複製到子主題的 function.php 裏面保存下,然後清除就好。

    /**
     * Plugin name: Fix for theme template file caching (WP Trac #42573)
     * Description: Flush the theme file cache each time the admin screens are loaded which uses the file list.
     * Author: Weston Ruter, XWP.
     * Plugin URI: https://core.trac.wordpress.org/ticket/42573
     */
    function wp_42573_fix_template_caching( WP_Screen $current_screen ) {
    	// Only flush the file cache with each request to post list table, edit post screen, or theme editor.
    	if ( ! in_array( $current_screen->base, array( 'post', 'edit', 'theme-editor' ), true ) ) {
    		return;
    	}
    	$theme = wp_get_theme();
    	if ( ! $theme ) {
    		return;
    	}
    	$cache_hash = md5( $theme->get_theme_root() . '/' . $theme->get_stylesheet() );
    	$label = sanitize_key( 'files_' . $cache_hash . '-' . $theme->get( 'Version' ) );
    	$transient_key = substr( $label, 0, 29 ) . md5( $label );
    	delete_transient( $transient_key );
    }
    add_action( 'current_screen', 'wp_42573_fix_template_caching' );
    風間
    參與者
    • 文章數量: 670
    @fengjian

    數字商城產品已更新至 5.3.1 , 使用很流暢而且方便。

    已購用户請到您的賬户中下載:

    https://mall.weixiaoduo.com/item/avada

正在查看 4 個帖子:1-4 (共 4 個帖子)
  • 哎呀,回覆話題必需登錄。

話題信息

  • 當前位於:Avada
  • 3 條回覆
  • 2 個參與人
  • 最後回覆:<a href="https://bbs.weixiaoduo.com/users/fengjian/" title=" 查看風間的個人資料" class="bbp-author-link"><span class="bbp-author-name"> 風間</span></a>
  • 上次活動:<a href="https://bbs.weixiaoduo.com/topic/23590/#post-24060" title=" 回覆至:解決 Avada 主題 5.3 更新到 WordPress 4.9 後,「頁面屬性」 框中缺少頁面模板的問題;">7 年、 2 月前</a>