Solved

Check if custom field is set

Posted on 2010-09-23
3
525 Views
Last Modified: 2012-05-10
Hi,

I have a few custom fields set in my post area.

Is there a way to test/check if the custom field is blank?

isset?
0
Comment
Question by:UltraFlux
3 Comments
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 33747580
What is the function of the custom field?
Is it a text area?
Is it an image?

You should be able to go to the post in the WP admin panel to check if the custom field has any content.
0
 

Author Comment

by:UltraFlux
ID: 33747610
I want to test the custom field before displaying on the website (not admin)

ex:
Custom Fields
price-new
price-sale
style

None of these fields are required. If one is blank I simply do not want it to show on the website.

ex:

Price New: $340
Price Sale: $250
Style: New

If "price-new" is not set website should not display "Price New: $340"

Basically I just need to test if the custom field is either set or empty...
0
 
LVL 14

Accepted Solution

by:
Dzynit earned 500 total points
ID: 33748296
      if (get_post_meta(x, 'price-new', true) != '') {
            echo (get_post_meta(x, 'price-new', true));
// or do what you want with the custom field info
        }

Where:
x = your post id number the custom field is on

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now