How to display Select form custom field info on homepage

Discussion in 'GeoCraft WordPress Theme' started by kentoliver, Jun 25, 2013.

Thread Status:
Not open for further replies.
  1. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Hey there, I am using a custom input field for one of my websites, and I am wondering how to display the information from that custom field on the homepage.

    I have successfully done this on the single listing page, by using:

    <?php if (strpos($p_price_per,'Hour') !== false) {
    echo '<span class="permonth-slash">/</span><span>hr. </span>';
    } else { echo ''; } ?>

    However on the homepage this does not work. I noticed that on the homepage to grab fields you are using something like this:

    <?php if (get_post_meta($post->ID, 'geo_address', true)): ?>
    <p class="f_post_meta"><img src="<?php echo TEMPLATEURL . '/images/location-icon.png'; ?>"/>&nbsp;<?php echo get_post_meta($post->ID, 'geo_address', true); ?></p>
    <?php endif; ?>


    I was wondering if you could give me a little php snippet that would let me load a custom select field. The custom select code being $p_price_per. with the selects I have set up being = Hour, Day, Week, Month, Year


    in short ^_^ {
    if p_price_per = 'Hour' then echo
    }

    Just not working when I do it

    Thanks again!
     
  2. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Just a bump ^_^

    Know this is possible because you offer select, radio and other options as custom fields. Just wondering how to call them on the homepage ^_^
     
  3. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Another bump.
     
  4. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello,

    Sorry for the delay.
    You can show any of your custom field on home page where you want.
    PHP:
    <?php
    echo get_post_meta($post->ID,'meta_key',true);
    ?>
    Please check image attached for reference.

    custom_field_on_home_page.png
     
  5. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Nitesh.

    You are going around my question. You are telling me how to grab a key.
    Which i already know because I showed you the following code in first post:

    <?php echo get_post_meta($post->ID, 'geo_address', true); ?>



    Please RE-Read what I am asking.

    I need to display a line of code IF the string I am calling equals a selected value.

    This is important because it lets me display depending on if my user has selected a field in the input / add listing process.

    Here is what I am asking for... again:

    If custom field key is value, then echo statement. otherwise do not.
    I CAN achieve this on my listing page, but not homepage.

    This is possible by doing this:

    <?php if (strpos($p_price_per,'Hour') !== false) {

    echo '<span class="permonth-slash">/</span><span>hr. </span>';

    } else {

    echo ''; } ?>

    I do not want to simply call the field because it is not what I am looking to accomplish. As it just calls a string, which is not what is needed.

    As this way I can set up if user selected price to be by hour, then to display code with span and class opposed to just a frontend variable.

    Thanks for your time Nitesh
     
  6. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
  7. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
  8. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello Kent,

    PM sent.
     
  9. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Thanks, Ill stop bumping and use the convo. Talk to you later on.
     
  10. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    I have found the solution. Sorry for all the posts.

    All the best,
    -Kent
     
Thread Status:
Not open for further replies.

Share This Page