Adding Custom Field…
-
I want to add a custom field value to a plugin I am using. The plugin is the Daily Top Ten Posts.
So, I found the part of the code I need to edit to control the output of the list of entry titles. What I want to do is use a custom field that I have to display the image.
So, this is the current code:
if ($widgets_num) { foreach ($widgets as $widget) { $postnum = $widget->postnum; $postcount = $widget->postcount; $id_post = $widget->ID; $title_post = $widget->post_title; if ($perma) { $home_url_perma = get_permalink($id_post); <strong>$postpic = get_post_custom_values("PostImage"); </strong> $todays_widget_temp .= "<strong><p class=\"news-img\"><img src=\"$postpic\" alt=\"$title_post\"> <div class=\"news-txt\"><a href=\"$home_url/?p=$id_post\" title=\"$text\">$title_post</a> <span class=\"count\">($postcount$views)</span></div></strong>\n"; } else { $todays_widget_temp .= "<strong><p class=\"news-img\"><img src=\"$postpic\" alt=\"$title_post\"> <div class=\"news-txt\"><a href=\"$home_url/?p=$id_post\" title=\"$text\">$title_post</a> <span class=\"count\">($postcount$views)</span></div></strong>\n"; } } }
*Note: I’ve added this variable to try to get my custom field to display: $postpic = get_post_custom_values(“PostImage”);
*Now, everything works fine, EXCEPT, I can’t get the $postpic to display. Which is a custom variable I added myself to call the “PostImage” custom field.
The only they that displays in the HTML output for the $postpic value is “Array”. Not any actual values.
I’ve also tried using
get_post_meta($post->ID, "PostImage", true);
in place of
get_post_custom_values("PostImage")
As you can see I’m not php expert, so I’m struggling trying to pull the “PostImage” custom value and placing it within this plugin.
If anyone could give me some advice, or show me how to do it I would greatly, greatly appreciate it.
Thanks,
Lindsey
- The topic ‘Adding Custom Field…’ is closed to new replies.