We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28099
    • 39 Posts
    I’m having a terrible time getting a WP post to show up on any given page in EVO.

    PieX used to be my goto snippet for this (been on REVO for over a year now), but it simply is not working anymore.

    I have also tried FeedBurner and newsParserX.

    Are there any other alternatives for doing this?
      • 4310
      • 2,310 Posts
      I use a snippet loosely based on one from the coding pad :
      <?php
      function url_exists($url) {
          // Version 4.x supported
          $handle   = curl_init($url);
          if (false === $handle)
          {
              return false;
          }
          curl_setopt($handle, CURLOPT_HEADER, false);
          curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 1);
          curl_setopt($handle, CURLOPT_TIMEOUT, 5);
          curl_setopt($handle, CURLOPT_FAILONERROR, true);  // this works
          curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox    
          curl_setopt($handle, CURLOPT_NOBODY, true);
          curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
          $connectable = curl_exec($handle);
          curl_close($handle);   
          return $connectable;
      }
      
      $i=0;
      $feed_url = 'http://www.your-wp-domain.com/blog/feed/';
      
      if (url_exists($feed_url)) {
      $xml = simplexml_load_file($feed_url);
      $o .='<div class="greybox-clear"></div>
      <div class="greybox">
      <h4>Blog Headlines</h4>';
      foreach($xml->channel->item as $key => $value)
      {
      if ($i < '1')
      {
      $stamp = explode(" ", $value->pubDate);
      $o .= '<p>
      <b><a href="'.$value->link.'" title="'.$value->title.'">'.$value->title.'</a></b><br />
         <i>'.$stamp[0].' '.$stamp[1].' '.$stamp[2].' '.$stamp[3].' </i><br />
      '.substr($value->description,0,100).'...
      </p>';
      }
      $i++;
      }
      $o .= '</div><!-- close greybox --><div class="greybox-clear"></div>';
      }
      
      else {
      $o .= '';
      }
      
      return $o;
      ?>

      Sorry, the html is mixed up in there, but you get the idea.
      Don’t forget to change the $feed_url value.
        • 28099
        • 39 Posts
        Kudos to you, bunk58! Thanks a ton. I have tried several different methods that either used to work or simply should have worked. I just don’t have enough programming experience to be able tell what was going wrong.

        But this worked on the first attempt. It will be my pleasure to simply edit the HTML.

        Thanks again.
          • 4310
          • 2,310 Posts
          No problem wink