[Resolved] Problem using custom fields within WordPress functions
I am creating a CMS, so I have run into some less common problems here. I am constantly having troubles using my custom fields within a WordPress function. For most of these, I have found ways around them, but there’s got to be a way to have your cake and eat it too.
Most recently I ran into this when wanting to put an RSS feed up on my pages. (No, I can’t use a widget, because the problem is that I need a different feed on the sidebar of each page and want to put it in the page template and have it pull the appropriate feed link from the page’s custom fields.)
I used code from http://codex.wordpress.org/Function_Reference/fetch_feed.
Here’s the part I’m having trouble with:
$rss = fetch_feed('http://example.com/rss/feed/goes/here');
So in order to use my custom fields, I need to do this:
$rss = fetch_feed('<?php $key="delicious-feed"; echo get_post_meta($post->ID,$key,true); ?>');
Or so I thought. It won’t display anything from that feed, and I know for a fact it works, because I tested it first with the actual url before putting in the code to pull the custom fields.
This has happened with more than just RSS feed readers, but with many things, usually when the php code has to go between ”. Any tips/tricks/help is much appreciated!
- The topic ‘[Resolved] Problem using custom fields within WordPress functions’ is closed to new replies.