Trying to get property of non-object in /.../class-category-sticky-post.php on line 200

WordPress啟用類別置頂插件category-sticky-post後,
類別內若無文章,會出現無貼文可置頂訊息:

    Trying to get property of non-object in /.../wp-content/plugins/category-sticky-post/class-category-sticky-post.php on line 200

解法如下: 在add_styles()方法,增加isset($post->ID) && 判別指令。

    category-sticky-post/class-category-sticky-post.php

      public function add_styles() {

        global $post;

        if( isset($post->ID) && is_archive() && '1' !== get_post_meta( $post->ID, 'category_sticky_post_border', true ) ) {
          wp_enqueue_style( 'category-sticky-post', plugins_url( '/category-sticky-post/css/plugin.css' ) );
        }
      }


參考:
https://tommcfarlin.com/category-sticky-post-2-1-0-support-post-types/

沒有留言:

how to call Java classes in a web page by cheerpj

🚀 在瀏覽器中直接執行 Java:CheerpJ v3 實作指南 長期以來,Java Applets 因為安全性與插件問題早已退出歷史舞台。但隨著 WebAssembly (Wasm) 技術的成熟,現在網頁安裝如下 CheerpJ v3 套件庫,就可以在瀏覽器中直接呼叫 ...

總網頁瀏覽量