Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom Feed Page Eleven40
Tagged: custom page, Eleven40-Pro, parse RSS
- This topic has 2 replies, 1 voice, and was last updated 9 years, 9 months ago by
winnydejong.
-
AuthorPosts
-
August 28, 2013 at 10:53 am #59242
winnydejong
MemberHi,
I'd like to build a 'Link Page', where the latest of my RSS feed on Pinboards shows. I've come up with this, but it isn't quite working. The title doesn't show; I can't figure out how to add pagination; and the sidebar and breadcrumbs are showing up underneath the links... (Guess I forget to close something... but what?)
Hopefully you can help. Thanks in advance!
Best, Winny
<?php /* Template Name: Pinboards Links */ // FORCE LAYOUT add_filter ( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); remove_action( 'genesis_loop', 'genesis_do_loop' ); //Add my latest links to page include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $feed = fetch_rss('http://feeds.pinboard.in/rss/u:winnydejong/t:ddj/'); // specify feed url $items = array_slice($feed->items, 0, 30); // specify first and last item ?> <?php if (!empty($items)) : ?> <?php foreach ($items as $item) : ?> <h3><a>"><?php echo $item['title']; ?></a></h3> <p><?php echo $item['description']; ?></p> <?php endforeach; ?> <?php endif; ?> <?php genesis(); ?>
August 28, 2013 at 11:49 am #59255winnydejong
MemberWorked some of it out by my own. Though the title of the page and the entry paragraph are still showing up under the footer... Any ideas? Help is very much welcomed! 🙂
<?php /* Template Name: Pinboard */ get_header(); ?> <div id="content" class="content"> <?php // FORCE FULL WIDTH LAYOUT //add_filter ( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); //remove_action( 'genesis_loop', 'genesis_do_loop' ); //Add my latest links to page include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $feed = fetch_rss('http://feeds.pinboard.in/rss/u:winnydejong/t:ddj/'); // specify feed url $items = array_slice($feed->items, 0, 20); // specify first and last item ?> <?php if (!empty($items)) : ?> <?php foreach ($items as $item) : ?> <h3><a href=""<?php">"><?php echo $item['title']; ?></a></h3> <p><?php echo $item['description']; ?></p> <?php endforeach; ?> <?php endif; ?> </div><!-- #content --> <?php get_sidebar(); ?> <?php get_footer(); ?> <?php genesis(); ?>
August 28, 2013 at 4:26 pm #59336winnydejong
MemberWith a little help I categorised all rss items by date; made a bullet list of the feed; added basic pagination; and fixed the title (shows up correctly).
My solution:
<?php /* Template Name: links */ // Filter toevoegen aan the_content() add_filter('the_content', 'winny_rss_content'); function winny_rss_content ($content) { //Add my latest links to page include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $feed = fetch_rss('http://feeds.pinboard.in/rss/u:winnydejong/t:ddj/?count=400'); // specify feed url $items = array_slice($feed->items, 0, 999); // specify first and last item if (!empty($items)) { // Per pagina $perpage = 20; $page = (int) $_REQUEST['pagina']; $pages = ceil(count($items) / $perpage); if ($page < 0 || $page >= $pages) { // Automatisch eerste pagina als pagina nummer niet bestaat $page = 0; } // Selectie maken $items = array_slice($items, $perpage * $page, $perpage); // $date definieren, maar geen inhoud $date = ''; foreach ($items as $item) { // Datum filteren $item['date'] = date('j-n-Y', strtotime($item['dc']['date'])); if ($date != $item['date']) { if ($date) { // Vorige lijst afsluiten $content .= '</ul>'; } // Nieuwe datum $date = $item['date']; // Nieuwe lijst begonnen $content .= '<h5>' . $item['date'] . '</h5>'; $content .= '<ul>'; } // Link aan lijst toevoegen $content .= '<li><h5><a>' . htmlentities($item['title'], ENT_QUOTES, 'UTF-8') . '</a></h5>'; $content .= '<p>' . htmlentities($item['description'], ENT_QUOTES, 'UTF-8') . '</p></li>'; } // Laatste lijst sluiten $content .= '</ul>'; if ($pages > 1) { // Meer dan 1 pagina $content .= '<p>Pagina: '; for ($i = 0; $i < $pages; $i ++) { if ($i == $page) { $content .= '<strong>' . ($i + 1) . '</strong>, '; } else { $content .= '<a>' . ($i + 1) . '</a>, '; } } // Einde pagina's $content = substr($content, 0, -2) . '</p>'; } } return $content; } genesis();
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.