尝试格式化输出的Wordpress.org上的简单饼图

时间:2013-10-09 18:58:52

标签: php wordpress simplepie

我正在使用我在wordpress.org帮助网站上找到的以下代码。我正在尝试为我的博客定制它。我的目标是抓住我的yahoo管道聚合Feed并将其显示在我的wordpress.org博客的页面上。

缓存代码无效,因为输出自昨天起未更新。在代码方面,我最好是新手,我的猜测是编码错误。谢谢你的帮助。

    <h2><?php _e( 'AUSTIN TEXAS REAL ESTATE NEWS', 'my-text-domain' ); ?></h2>

    <?php // Get RSS Feed(s)
    include_once( ABSPATH . WPINC . '/feed.php' );

// Get a SimplePie feed object from the specified feed source.
    $rss = fetch_feed('http://feeds.feedburner.com/AustinRealEstateNewsInformation');

    if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly

// Figure out how many total items there are, but limit it to 25. 
    $maxitems = $rss->get_item_quantity( 25 ); 

// Build an array of all the items, starting with element 0 (first element).
    $rss_items = $rss->get_items( 0, $maxitems );

//set cache duration
    function return_1800( $seconds )
{
  // change the default feed cache recreation period to 30 minutes
  return 1800;
}

    add_filter( 'wp_feed_cache_transient_lifetime' , 'return_1800' );
    $feed = fetch_feed( $feed_url );
    remove_filter( 'wp_feed_cache_transient_lifetime' , 'return_1800' );

    endif;
?>

<ul>
    <?php if ( $maxitems == 0 ) : ?>
        <li><?php _e( 'No items', 'my-text-domain' ); ?></li>
    <?php else : ?>
        <?php // Loop through each feed item and display each item as a hyperlink. ?>
        <?php foreach ( $rss_items as $item ) : ?>
            <li>
                <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
                    <?php echo esc_html( $item->get_title() ); ?>.
<?php printf( __( '.%s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>.
                </a>
            </li>
        <?php endforeach; ?>
    <?php endif; ?>
</ul>

0 个答案:

没有答案