• Hi wonder if anyone knows the answer to this;

    I have a theme which I’m editing that doesn’t have custom fields enabled; I’ve installed the types custom field plugin;

    Basically I’m not sure if I’m formatting the php correctly as when I do the tetx isn’t displayed within the div tag as expect it just displays outside of it and unformatted, I would have expected the CSS to style it; however if i replace the echo function with just some html text it displasy fine;

    Can anyone suggest whther its possible?

    heres’ the code in question;

    if ( sizeof( $exclude_info )!=2 ) {
    			//display the item info
    			$html.='<div class="pg-info">';
    			$html.='<div class="pg-details'.$add_class.'">';
    			if ( !in_array( 'title', $exclude_info ) ) {
    				$html.='<h2>'.$post->post_title.'';
    				$html.='<br>';
    				$html.='<div class="projectinfo">';
    				$projectinfo = types_render_field('project-info', array('output'=>"html"));
     				echo($projectinfo);
    				$html.='</div>';
    				$html.='</div>';
    				$html.='</h2>';
    			}
    			$html.='</div>';
    		}
    
    		$html.='</a></div>';
    		$html.='</div>';
    
    		return $html;
    	}
    }

    Thanks
    Darren

Viewing 2 replies - 1 through 2 (of 2 total)
  • you are using echo($projectinfo); which will output the string immediately before the othere html gets concatenated and returned;

    change that line to:
    $html.=$projectinfo;

    Thread Starter stiwdio

    (@stiwdio)

    Thanks alchymyth that works like a charm 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom Field Correct Php Formatting’ is closed to new replies.