Solved

Wordpress Custom Fields from a Post

Posted on 2014-01-20
3
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

734 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