• hi, i’m newbie in php
    how to add html code in this code

    function the_title($before = '[html code here]', $after = '', $echo = true) {
    	$title = get_the_title();
    
    	if ( strlen($title) == 0 )
    		return;
    
    	$title = $before . $title . $after;
    
    	if ( $echo )
    		echo  $title;
    	else
    		return  $title;
    }

    i want to add code like this

    <div style=”float:left; margin-right: 5px”><img src=”<?php $key=”icon”; echo get_post_meta($post->ID, $key, true); ?>” /></div>

    thank

Viewing 2 replies - 1 through 2 (of 2 total)
  • where do you want to add the code so???

    ooops. sorry. I did not read the title. well, so you want such a html code to appear before title, dont you?
    Then do following.

    function the_title($before = '[html code here]', $after = '', $echo = true) {
    	$title = get_the_title();
    
    	if ( strlen($title) == 0 )
    		return;
             $imgname = get_post_meta($post->ID, $key, true);
             $title = '<div><div style="float:left; margin-right: 5px"><img src="'.$imgname.'" /></div><div style="float:left; margin-right: 5px">'.$title.'</div></div>';
    	$title = $before . $title . $after;
    
    	if ( $echo )
    		echo  $title;
    	else
    		return  $title;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add icon in every title post?’ is closed to new replies.