Solved

Wordpress Custom Fields from a Post

Posted on 2014-01-20
3
332 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
ID: 39795608
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
ID: 39795641
Thanks for the help!  I also for to echo it.
0
 
LVL 17

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
Wordpress Horizontal Drop-Down Menu In this tutorial I will show you had to add a WordPress horizontal navigation menu to your theme. I have searched and searched for a good tutorial on creating a WordPress nav menu without adding a plug-in or us…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

777 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