外部ワードプレスブログのブログリストを表示するように働いています。 コードでPHPの問題があり、それが唯一の代わりにこれを試してみてください一つだけ外部Wordpressブログフィード表示
add_shortcode('first', 'foobar_func');
function foobar_func($atts){
$feed = fetch_feed('https://wordpress.org/news/feed/');
if (!is_wp_error($feed)):
$maxitems = $feed->get_item_quantity(3);
$rss_items = $feed->get_items(CURL_HTTP_VERSION_1_0, $maxitems);
endif;
if ($maxitems == 0) {
return '<li>No items.</li>';
} else foreach ($rss_items as $item) {
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $item->get_content(), $matches);
$first_img = $matches [1][0];
$testts = esc_html($item->get_title());
}
return $testts;
}
基本的なデバッグを試しましたか? – ProEvilz
はい、私はしました。何かが "foreach"に混乱しています – Eurasia
なぜあなたは 'CURL_HTTP_VERSION_1_0'を持っていますか? 0と設定すると、ドキュメントのように – ProEvilz