Support » Fixing WordPress » Custom Fields

  • Resolved Debb477


    I have managed to create a Custom Field on my post but how do I get it to show up on my page. I’ve read and reread the Codex instructions but it is all Greek to me. Pls help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • you need to edit your theme files for the custom fields to show up, they don’t magically appear.
    So, grab notepad or some other texteditor and start coding 🙂

    That’s the part that’s confusing, I thought Word press was user friendly but it appears you need some training in coding!

    Well, yes, to the extent that there’s no way for your theme to know which custom field to pull and what to do with it. You might also find themes with custom field support built in, or I’m sure there are widgets/plugins out there that handle them in some way.

    WordPress is user friendly out-of-the-box, once you start customizing, you need code. But even then it’s simple, most of the time, as long as you have basic copy/pasting skills and know how to use FTP. Or actually, you can use the theme editor built-in to WordPress to add stuff like that.

    Explain why you need custom fields? Maybe there are simpler solutions that won’t require you to code.

    I want to be able to add a section Currently Reading; Today’s Mood as explained in Codex – Using Custom Fields. My problem is knowing where to insert the template tag.

    If you want it on the single post page then single.php, if you want it elsewhere then also update the appropriate template files..

    Which depends which files exist for your theme, check what you have and update the necessary files, for the cases you want it to appear..

    An example of custom field :

    <div class="loopinindex">
    		<!-- starting the loop -->
    		if (have_posts()) :
    		while (have_posts()) :
    		<?php the_title(); ?>
    		<?php the_content(); ?>
    		<!-- pulling the custom field -->
    		$music = get_post_meta($post->ID, "listening", true); ?>
    		<!-- printing the custom field -->
    		<?php echo $music ; ?>
    		<?php endwhile;

    listening being the name of the custom field.
    Hope that helps.

    You could also do the following. I’ll assume the custom field is called ‘Currently Reading’…

    <?php $curread = get_post_custom_values(“Currently Reading”); if ( $curread != ” ) { ?>Currently Reading: <?php echo $values[0]; ?><?php } ?>

    <?php the_content(); ?>

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom Fields’ is closed to new replies.