It may be that $post->ID is not available. Did you declare $post as a global?
Sorry, I don’t know about declaring $post as global, could you send me some documentation? I’m new to WordPress and PHP.
Thanks!!
Just add global $post; after your function declaration.
function blah_blah() {
global $post;
// rest of function
}
Ok I tried it this way
$rss = fetch_feed('<?php $key="delicious-feed"; echo get_post_meta($post->ID,$key,true); ?>'); {
global $post
if (!is_wp_error( $rss ) ) : }
// Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
and it gets error ” Parse error: syntax error, unexpected T_IF, expecting ‘,’ or ‘;’ in /home/…”
and this way
$rss = fetch_feed('<?php $key="delicious-feed"; echo get_post_meta($post->ID,$key,true); ?>') {
global $post
if (!is_wp_error( $rss ) ) : }
// Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
and get this error: “Parse error: syntax error, unexpected ‘{‘ in /home/hrcadmin/public_html/wp-content/themes/catch-box-child/member.php on line 126”
Do I need to declare the global $post before I call the custom field?
Sorry and thank you!
I think you are missing the semi-colon after $posts.
Hmmm didn’t help. Error this time:
” Parse error: syntax error, unexpected ‘{‘ in /home/hrcadmin/public_html/wp-content/themes/catch-box-child/member.php on line 126″
I see an extra closing brace at the end of this line:
if (!is_wp_error( $rss ) ) : }
Remove that, and if it still doesn’t work, put the entire member.php file in a pastebin and post a link to it here.
Ok didn’t work. I pasted it here: http://pastebin.com/2zjRP0ze.
Thank you for your help!!
You created that as a private paste, so only you can view it.
Ooops sorry I made it public. Never used paste pin before.
I get no errors when I compile the code in the pastebin, so I can’t diagnose the problem.
Do you still get the same error?
I’m not getting an error, the page is displaying, but it’s not pulling the feed it should be. The custom field being pulled, “delicious-feed” is this: http://feeds.delicious.com/v2/rss/wahousegop/alexander. So there are two stories that should be pulling the area “In the News” on the Web page and it’s not.
This code does not look right to me:
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('<?php $key="delicious-feed"; echo get_post_meta($post->ID,$key,true); ?>');
global $post;
I believe it should be this:
// Get a SimplePie feed object from the specified feed source.
global $post;
$key = 'delicious-feed';
$rss = fetch_feed( get_post_meta($post->ID,$key,true) );
cue >angelic voices<
Hooray! Thank you so much!! I really appreciate it!!