Quantcast
Channel: fetch_feed(custom field url) printing out the url rather then using it | WordPress.org
Viewing all articles
Browse latest Browse all 18

fetch_feed(custom field url) printing out the url rather then using it

$
0
0

Hi,

I am creating a website that gathers rss feeds from various sources and displays them by topic on different pages. I am creating my own template pages. I am trying to use 1 template for each page and then just have the feed url change dynamically using a custom field that I created on each page within WordPress.

Here’s a snippet of my code:

<?php 

$page_id = 1391; //ID of page from your WP admin panel
$page_data = get_page( $page_id );
echo $page_data->post_content; // Show page content

$url = get_custom_field_value('address', true); //custom field
?>

<?php include_once(ABSPATH. WPINC. '/feed.php');

$afl_link = fetch_feed($url); //making use of custom field rather then having fetch_feed('http://feeds.feedburner.com/example');

$maxitems = $afl_link->get_item_quantity(23);
$afl_items = $afl_link->get_items(0,$maxitems);

if (!rss_items) {
echo "There are no Feeds";
} else {

$i = 0;
foreach ($afl_items as $item) {
?>

//Echo out the RSS feed details
<p><a>get_permalink(); ?>" target="_blank">
<?php echo $item->get_title(); ?></a><p>

[Edited: Please ensure that all code snippets are posted within in backticks. Or use the code button]

So when this runs, rather then displaying the permalink and the title of each feed, it is simply printing out the url – http://feeds.feedburner.com/example – one and then stops. I am not sure whether you can have a url address as a custom field or not. Any advice would be greatly appriciated.


Viewing all articles
Browse latest Browse all 18

Trending Articles