centree
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: should fetch_feed() be cleared if using multiple rss feeds on a pageI’m not sure but in my case this coding is valid for me.
Here is a code from WordPress Reference.
http://codex.wordpress.org/Function_Reference/fetch_feed<h2><?php _e('Recent news from Some-Other Blog:'); ?></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://example.com/rss/feed/goes/here'); if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly // Figure out how many total items there are, but limit it to 5. $maxitems = $rss->get_item_quantity(5); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items(0, $maxitems); endif; ?> <ul> <?php if ($maxitems == 0) echo '<li>No items.</li>'; else // Loop through each feed item and display each item as a hyperlink. foreach ( $rss_items as $item ) : ?> <li> <a href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'> <?php echo esc_html( $item->get_title() ); ?></a> </li> <?php endforeach; ?> </ul>If you change all”$rss” to “$rssA“,”rssB” or other unique word,you could display more than 2 columns in the same page.
Remind that you should change “$rss_items” to “$rssA_items“,”rssB_items” also.Here is the full code that has been changed.
<h2><?php _e('Recent news from Some-Other Blog:'); ?></h2> <?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/feed.php'); // Get a SimplePie feed object from the specified feed source. $rssA = fetch_feed('http://example.com/rss/feed/goes/here'); if (!is_wp_error( $rssA ) ) : // Checks that the object is created correctly // Figure out how many total items there are, but limit it to 5. $maxitems = $rssA->get_item_quantity(5); // Build an array of all the items, starting with element 0 (first element). $rssA_items = $rssA->get_items(0, $maxitems); endif; ?> <ul> <?php if ($maxitems == 0) echo '<li>No items.</li>'; else // Loop through each feed item and display each item as a hyperlink. foreach ( $rssA_items as $item ) : ?> <li> <a href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'> <?php echo esc_html( $item->get_title() ); ?></a> </li> <?php endforeach; ?> </ul>Again, I’m not sure because I’m not professional of coding, but it works well for me.
Forum: Plugins
In reply to: [Plugin: Registered Users Only] Released under GPL?Thank you for your quick reply!
I am using this plug-in,
also I’m interested in other plug-ins you wrote.I’m going to use some of them if it would be suitable for me.
🙂
Viewing 2 replies - 1 through 2 (of 2 total)