質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

2回答

2989閲覧

Notice: Trying to get property of non-objectについて

ryuujinn

総合スコア72

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2016/01/17 04:46

Notice: Trying to get property of non-object in C:\Users\xxxxxx\Desktop\xxxxxx\wordpress\wp-content\plugins\ps-auto-sitemap\ps_auto_sitemap.php on line 61

wordpressのプラグインで上記のエラーがでるようになってしまいました

以下がエラーコードが記述されている部分ですが、どのように記述し直すとエラーが解決しますでしょうか?

58行目から150行目までコード記述しておきますのでよろしくお願いします

function ps_auto_sitemap_init() {
$this->option = get_option( 'ps_sitemap' );
if ( ! $this->option ) {
$this->set_default_options();
$this->option = get_option( 'ps_sitemap' );
}
}

function replace_sitemap_content( $content ) { global $post; if ( $this->option['post_id'] && $post->ID == $this->option['post_id'] ) { if ( isset( $_GET['category'] ) && $category = get_category( (int)$_GET['category'] ) ) { $sitemap_content = $this->make_category_sitemap( $category ); } else { $cache_dir = $this->check_cache_dir(); if ( $cache_dir && file_exists( $cache_dir . '/site_map_cache.html' ) && $this->option['use_cache'] ) { $sitemap_content = file_get_contents( $cache_dir . '/site_map_cache.html' ); } else { $sitemap_content = $this->create_sitemap_content(); } } $content = preg_replace( '/(<p><!-- SITEMAP CONTENT REPLACE POINT --><\/p>|<!-- SITEMAP CONTENT REPLACE POINT -->)/', $sitemap_content, $content, 1 ); } return $content; } function create_sitemap_content() { if ( $this->option['post_tree'] == '1' ) { $category_tree = $this->make_category_tree( $this->option['ex_cat_ids'] ); $post_list = $this->make_post_list( $this->option['ex_post_ids'], $category_tree, $this->option['disp_level'], 1, false ); } else { $post_list = ''; } $page_on_front = get_option( 'page_on_front' ); $ex_pages = $this->option['ex_post_ids']; if ( get_option( 'show_on_front') == 'page' && $page_on_front ) { if ( $ex_pages ) { $ex_pages .= ',' . $page_on_front; } else { $ex_pages = $page_on_front; } } $sitemap_content = "<ul id=\"sitemap_list\" class=\"sitemap_disp_level_" . $this->option['disp_level'] . "\">\n"; if ($this->option['home_list'] ) { $sitemap_content .= '<li class="home-item"><a href="' . get_bloginfo( 'url' ) . '" title="' . get_bloginfo( 'name' ) . '">' . esc_html( get_bloginfo( 'name' ) ) . "</a></li>\n"; } if ( $this->option['disp_first'] == 'post' ) { $sitemap_content .= $post_list; if ( $this->option['page_tree'] == '1' ) { $sitemap_content .= wp_list_pages( 'title_li=&echo=0&exclude=' . $ex_pages . '&depth=' . $this->option['disp_level'] ); } } else { if ( $this->option['page_tree'] == '1' ) { $sitemap_content .= wp_list_pages( 'title_li=&echo=0&exclude=' . $ex_pages . '&depth=' . $this->option['disp_level'] ); } $sitemap_content .= $post_list; } $sitemap_content .= "</ul>\n"; if ( ( $cache_dir = $this->check_cache_dir() ) && $this->option['use_cache'] ) { $this->check_htaccess( $cache_dir ); $handle = @fopen( $cache_dir . '/site_map_cache.html', 'w' ); if ( $handle ) { fwrite( $handle, $sitemap_content ); fclose( $handle ); } } return $sitemap_content; }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

https://ja.forums.wordpress.org/topic/150129


ブログ http://kooen.sakura.ne.jp/ooyodo/

のタイトルの上に次の様な文字が表示されました。
Strict Standards: Redefining already defined constructor for class ps_auto_sitemap in /home/kooen/www/ooyodo/wp-content/plugins/ps-auto-sitemap/ps_auto_sitemap.php on line 37
次々とエラ-が出てきます
サイドのカレンダ-の曜日の表示も消えてしまいました。


問題解決しました。

すべてのプラグインを無効化して、動作するので
プラグインを1つずつ有効化して行く内に、すべて解決しました。
ありがとうございました。


役立たずな質問者。

こういう役立たずにならないために、ネットで質問して自己解決したら、解決方法を必ず書きましょう。

投稿2016/01/17 07:57

編集2016/01/17 07:59
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ずらっとコードを貼り付けるよりも、問題の61行目のコードがどれかわかるようにしてもらったほうがいいです。

投稿2016/01/17 04:50

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ryuujinn

2016/01/17 07:26

見にくくてすいません 58行目     function ps_auto_sitemap_init() { 59行目 $this->option = get_option( 'ps_sitemap' ); 60行目 if ( ! $this->option ) { 61行目  $this->set_default_options(); 62行目  $this->option = get_option( 'ps_sitemap' ); 63行目   } 64行目 } になります 説明が分かりにくくてすいませんがよろしくお願い致します
退会済みユーザー

退会済みユーザー

2016/01/17 07:47

> Notice: Trying to get property of non-object って、オブジェクトでない値のプロパティを取得しようとしたエラーなんですが、 $this->set_default_options(); これはメソッド実行なのでおかしいな… 行番号ずれてるのかな…
退会済みユーザー

退会済みユーザー

2016/01/17 07:54 編集

なるほど、 http://k-popykurashiki.jp/?p=7 燦々たる状況になってるページに、同様のエラーがありました。 Notice: Trying to get property of non-object in /home/popykurasiki/k-popykurashiki.jp/public_html/wp-content/plugins/ps-auto-sitemap/ps_auto_sitemap.php on line 495 wordpressって、エラーのlineと現実のコードの場所が一致しなかったりするから地雷生成システムなのかなって。 実際のコードを見ていじりながらでないと、ここにいる僕には解決難しいです…
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問