Solved

Wordpress Custom Fields from a Post

Posted on 2014-01-20
3
327 Views
Last Modified: 2014-01-20
On my website, some pages have a lower third section that I want to make editable and separate from the page itself.

I created a category called "lower-thirds" and created a new post(#38) with 2 custom fields.

Here's my code:

<?php
$post_id = 38;
$queried_post = get_post($post_id);
?>
                            
<div class="bottom_third_img">
<img src="<?php get_post_meta($post_id->ID,'bottom_third_head',true);?>" width="673" height="38">
</div>

<div class="bottom_third_txt">
        <div class="bottom_third_info">
           <h2><?php echo $queried_post->post_title; ?></h2>
           <p><?php echo $queried_post->post_content; ?></p>
</div>
<div class="bottom_third_picture">
            <img src="<?php get_post_meta($post_id->ID,'bottom_third_image',true);?>" alt="Alt Text Here..." width="161" height="100">                                
</div>
<div style="clear:both;"></div>
</div>

Open in new window


The custom field values are saved for post #38, but the img src tag is blank when I run this code.

The text and header is working as it is supposed to.

Any suggestions?
0
Comment
Question by:slightlyoff
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
OmniUnlimited earned 500 total points
Comment Utility
You already assigned a post ID.  Try this instead:

<?php
$post_id = 38;
$queried_post = get_post($post_id);
?>
                            
<div class="bottom_third_img">
<img src="<?php get_post_meta($post_id,'bottom_third_head',true);?>" width="673" height="38">
</div>

<div class="bottom_third_txt">
        <div class="bottom_third_info">
           <h2><?php echo $queried_post->post_title; ?></h2>
           <p><?php echo $queried_post->post_content; ?></p>
</div>
<div class="bottom_third_picture">
            <img src="<?php get_post_meta($post_id,'bottom_third_image',true);?>" alt="Alt Text Here..." width="161" height="100">                                
</div>
<div style="clear:both;"></div>
</div> 

Open in new window

0
 
LVL 1

Author Closing Comment

by:slightlyoff
Comment Utility
Thanks for the help!  I also for to echo it.
0
 
LVL 17

Expert Comment

by:OmniUnlimited
Comment Utility
Glad to assist.  Let me know if you have any further issues.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I want to start by talking about the use of plug-ins for WordPress. I started a web-site for a company I was working for a few years ago; I had extremely basic knowledge of HTML. I am a Graphic Designer by trade so I invited the opportunity as a cha…
What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now