Support » Fixing WordPress » How to call a Custom Field value

  • Hi there,
    I’m trying to modify a little bit my template by adding some custom values in some places of the template, but I don’t know how to do it and it’s becoming very frustrating. For example, in the table that is in the bottom of this page (http://robotsaspirador.es/comparativa-roomba/) I would like to call some custom values that are already implemented in my theme, and to display theme. What I would like to display is the updated price of each item, as know I have to update it periodically.
    Could anyone help me a little bit with that? I work with the wordpress editor, so it should be html code to insert on it.
    Thanks!
    Sil

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi !

    Lets say your custom field you named is “system”, create a variable which retrieves the value of that field:
    <?php $systemvalue = get_post_meta($post->ID, 'system', true); ?>

    Now you want to display that variable you just created ($systemvalue) by writing: if variable $systemvalue exists, then echo (display) that value else echo (display) “value missing”:

    <?php  if ($systemvalue) {
    				echo "<p>".$systemvalue."</p>";
    
    				}
    				else  {
    				 echo "<p>value missing</p>";
    				 }
    		?>

    You can put these two bits of code in the template page’s loop you want (home, category, post etc) and you will hav the custom field display for each post.

    Hello, I have a problem with the same theme but the problem I have is a bit diferent, The issue is the 3 botom widget area of this site http://robot-aspirador-es.es/ is if I add text in the first left colum I get raw code showing, the only way that the raw code does not show is with twitter widget, but if I want to add normal text I get raw code showing also if I try to switch the botom widgets around I get raw code showing.
    Thanks

    Hi,
    I have a problem too in my web site http://www.angelsmasajes.com, but I when I add shortcodes in the first column. Is too estrange, only with this column :S

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to call a Custom Field value’ is closed to new replies.