Forums

[resolved] Function using Custom Field content (4 posts)

  1. artfulalibi
    Member
    Posted 1 year ago #

    Hello. I apologize ahead of time, my PHP is only basic.

    I am using some custom field data to pass a variable to a function in my theme template. However, when I don't use the custom field, it causes an error in the function because it has no data. Is there any way for me to write an if statement based on the custom field data, kind like of if function_exists?

    Here is my code:

    <?php
    	setZoom(3);
            setWidth(400);
            setHeight(350);
    	addAddress(get_meta('building_address'));
    	showMap();
    	?>

    Basically I want something that says if the key 'building_address' has data in it, run this function.

    Thanks everyone!

  2. MichaelH
    moderator
    Posted 1 year ago #

  3. artfulalibi
    Member
    Posted 1 year ago #

    Hmm. I don't see how to make that post relevant to this one.

    The key being passed is going to be a string, how do I test to see if it is empty, or has content. I guess that is what I am asking.

  4. artfulalibi
    Member
    Posted 1 year ago #

    O I get it! Thanks Michael.

Topic Closed

This topic has been closed to new replies.

About this Topic