WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Template
Displaying on Post (4 posts)

  1. nlck1
    Member
    Posted 3 years ago #

    Hello,
    I have problems with the fields showing up on the posts. I'm not really good with php. What I have been doing is putting this into the bottom of functions.php (theme functions.php)

     function getCustomField($theField) {
    	global $post;
    	$block = get_post_meta($post->ID, $theField);
    	if($block){
    		foreach(($block) as $blocks) {
    			echo $blocks;
    		}
    	}
    }

    And this into single.php

    <?php getCustomField('Day Number'); ?>

    This is my settings.

     [Day Number]
    type = text
    size = 10
    output = true
    

    I'm using Suffusion theme and I have no idea what I'm doing wrong.

    Thanks in advance

    http://wordpress.org/extend/plugins/custom-field-template/

  2. nlck1
    Member
    Posted 3 years ago #

    Update:
    Found that I should only need to add

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

    to the template but I have no idea which file or line.

    Thanks.

  3. Tara Rotten
    Member
    Posted 2 years ago #

    Hey

    Do you know how to add the custom field name as well as the field content
    e.g:

    Day Number: field content

    ??

  4. blitz999
    Member
    Posted 2 years ago #

    Yes, this takes a little getting your head round.

    Nick1. Your code goes into the page (ie: page.php or single.php) in the position you want it to show.

    I'm trying to get these custom fields to show in a widget - anyone know how to do that?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic