1

functions.php でこの関数を使用して、投稿のサムネイルを取得し、RSS フィードに追加しようとしてます。

function featuredtoRSS($content)
{
    global $post;
    if ( has_post_thumbnail( $post->ID ) ) {
        $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content;
    }
    return $content;
}

add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');

問題は、サーバーがクラッシュすることです。500 エラーが発生します。行をコメントアウトしてadd-filterもエラーはありません。

ここで何が起こっているのか誰か手を貸してくれませんか? Wordpress 3.1.2、Thesis Theme を使用しています。

ありがとう!

4

1 に答える 1

1

開発サイトでコードをテストしましたが、期待どおりに機能します。サムネイル後のサポートが有効になっていないため、機能しない場合があります。コーデックスから:

To enable Post Thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file.

ソース:

http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

于 2011-05-04T01:53:06.033 に答える