Custom Feed Page Eleven40

Community Forums Forums Design Tips and Tricks Custom Feed Page Eleven40

This topic is: resolved

This topic contains 2 replies, has 1 voice, and was last updated by  winnydejong 1 year ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #59242

    winnydejong
    Participant
    Post count: 27

    Hi,

    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]<?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>"><?php echo $item['title']; ?></h3>
    <p><?php echo $item['description']; ?></p>

    <?php endforeach; ?>
    <?php endif; ?>

    <?php genesis(); ?>[/php]

    #59255

    winnydejong
    Participant
    Post count: 27

    Worked 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]<?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>"><?php echo $item['title']; ?></h3>
    <p><?php echo $item['description']; ?></p>

    <?php endforeach; ?>
    <?php endif; ?>
    </div><!– #content –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    <?php genesis(); ?>[/php]

    #59336

    winnydejong
    Participant
    Post count: 27

    With 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]<?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 .= ‘‘;
    }

    // Nieuwe datum
    $date = $item['date'];

    // Nieuwe lijst begonnen
    $content .= ‘<h5>’ . $item['date'] . ‘</h5>’;
    $content .= ‘

    ‘;

    if ($pages > 1) {
    // Meer dan 1 pagina
    $content .= ‘<p>Pagina: ‘;

    for ($i = 0; $i < $pages; $i ++) {
    if ($i == $page) {
    $content .= ‘‘ . ($i + 1) . ‘, ‘;
    } else {
    $content .= ‘‘ . ($i + 1) . ‘, ‘;
    }
    }

    // Einde pagina’s
    $content = substr($content, 0, -2) . ‘</p>’;
    }
    }

    return $content;
    }

    genesis();[/php]

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.