• Ok, I have a brand new install… summerlawns.com/blog/

    and can see my rss feed xml here: https://www.summerlawns.com/blog/?feed=rss2

    I have tried several different way to display the content on another page, located here:
    https://www.summerlawnsinc.com/summerlawnsinc/blog.php

    using php code I found on this site, and other sites … however, no matter what I do, I cannot get past what is being displayed there now…like it is calling some default post metadata from the install files…

    what am i missing here??

    The code I am using is this:
    `<?php
    global $text, $maxchar, $end;
    function substrwords($text, $maxchar, $end=’…’) {
    if (strlen($text) > $maxchar || $text == ”) {
    $words = preg_split(‘/\s/’, $text);
    $output = ”;
    $i = 0;
    while (1) {
    $length = strlen($output)+strlen($words[$i]);
    if ($length > $maxchar) {
    break;
    } else {
    $output .= ” ” . $words[$i];
    ++$i;
    }
    }
    $output .= $end;
    } else {
    $output = $text;
    }
    return $output;
    }

    $rss = new DOMDocument();
    $rss->load(‘https://www.summerlawns.com/blog/?feed=rss2&#8217;); // <– Change feed to your site
    $feed = array();
    foreach ($rss->getElementsByTagName(‘item’) as $node) {
    $item = array (
    ‘title’ => $node->getElementsByTagName(‘title’)->item(0)->nodeValue,
    ‘desc’ => $node->getElementsByTagName(‘description’)->item(0)->nodeValue,
    ‘link’ => $node->getElementsByTagName(‘link’)->item(0)->nodeValue,
    ‘date’ => $node->getElementsByTagName(‘pubDate’)->item(0)->nodeValue,
    );
    array_push($feed, $item);
    }

    $limit = 10; // <– Change the number of posts shown
    for ($x=0; $x<$limit; $x++) {
    $title = str_replace(‘ & ‘, ‘ & ‘, $feed[$x][‘title’]);
    $link = $feed[$x][‘link’];
    $description = $feed[$x][‘desc’];
    $description = substrwords($description, 100);
    $date = date(‘l F d, Y’, strtotime($feed[$x][‘date’]));
    echo ‘<p>‘.$title.’
    ‘;
    echo ‘<small>Posted on ‘.$date.’</small></p>’;
    echo ‘<p>’.$description.'</p>’;
    }
    ?>

Viewing 1 replies (of 1 total)
  • Hi,

    Hopefully I’m understanding this right. You want to display your blog on another page, is that correct?

    If so, you can change this by going to your admin dashboard, and then going to Settings > Reading. Under “Front page displays” click the radio button for “A static page (select below)” and choose a page you want for your homepage and one for your posts (blog) page. Hit save at the bottom. That will allow any other page you previously created to list your posts.

    Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Display posts on non wodpress page’ is closed to new replies.