WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: FreshPost] Dynamic Queries for RSS

[Resolved] [Plugin: FreshPost] Dynamic Queries for RSS

  • I’m using this plug-in as part of a larger project. One thing I’m stuck on is how to dynamically aggregate persistent search results from sites like Icerocket and Yahoo (they offer RSS for search) for each entry. Here’s what works:

    <h3 class="site-subtitle"><?php echo get_post_meta($post->ID, "Company", true); ?> Aggregator</h3>
    
    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/rss.php');
    $rss = fetch_rss('http://www.icerocket.com/search?tab=web&q=companyname&rss=1');
    $maxitems = 10;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    
    <?php foreach ( $items as $item ) : ?>
    <ul>
    <li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['description']; ?>'>
    <?php echo $item['title']; ?>
    </a></li>
    </ul>

    and here’s what doesn’t work:

    <h3 class="site-subtitle"><?php echo get_post_meta($post->ID, "Organization", true); ?> Aggregator</h3>
    
    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/rss.php');
    $rss = fetch_rss('http://www.icerocket.com/search?tab=web&q=<?php echo get_post_meta($post->ID, "Company", true); ?>&rss=1');
    $maxitems = 10;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    
    <?php foreach ( $items as $item ) : ?>
    <ul>
    <li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['description']; ?>'>
    <?php echo $item['title']; ?>
    </a></li>
    </ul>

    As you can see, I’m trying to substitute a normal search query company with this string that calls data from Freshpost <?php echo get_post_meta($post->ID, "Company", true); ?> but it doesn’t work. It just breaks the code. Any ideas as to how I can call a dynamic query so that the company name is searched and returned as an RSS feed?

Viewing 1 replies (of 1 total)
  • Nevermind, the solution is:

    <?php 
    
    $org = get_post_meta($post->ID, "Organization", true);
    print $org;
    
    ?> Aggregator</h3>
    
    <?php // Get RSS Feed(s)
    if ($org) {
    include_once(ABSPATH . WPINC . '/rss.php');
    $url = 'http://www.icerocket.com/search?tab=web&q='. urlencode($org) . '&rss=1';
    // print $url;
    $rss = fetch_rss($url);
    $maxitems = 10;
    $items = array_slice($rss->items, 0, $maxitems);
    ?>
    <?php foreach ( $items as $item ) : ?>
    <ul>
    <li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['description']; ?>'>
    <?php echo $item['title']; ?>
    </a></li>
    </ul>

    Basically, you need to assign the company name to a variable which is then printed as part of the URL.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] [Plugin: FreshPost] Dynamic Queries for RSS’ is closed to new replies.
Skip to toolbar