Primer Paràgraf

aquesta funció php ens ajuda a automatitzar la presentació de les nostres pàgines web atorgant un atribut CSS al primer paràgraf del nostre html. És obvi que podem utilitzar qualsevol altra etiqueta html.
Mitjançant el full d'estil podem donar presentació i focalitzar l'atenció del usuari (podem indicar que la lletra sigui griuxuda i d'un color concret, etc..).
<?php
function str_replace_once($needle , $replace , $haystack){ 
    // Looks for the first occurence of $needle in $haystack 
    // and replaces it with $replace. 
    $pos = strpos($haystack, $needle); 
    if ($pos === false) { 
        // Nothing found 
    return $haystack; 
    } 
    return substr_replace($haystack, $replace, $pos, strlen($needle)); 
}
$content = "<p>hola1</p> <p>hola2</p>";
print str_replace_once('<p>', '<p class="first">', $content);
?>
el resultat que obtenim és el següent
<p class="first">hola1</p> <p>hola2</p>
funció trobada al fòrum
http://www.webmaster-talk.com/php-forum/21334-str_replace-only-once-occurence-only.html#post109511

Aquí l'opció per utilitzar amb wordpress, cal afegir el codi al vostre arxiu functions.php
add_filter('the_content', 'first_p_style');
function first_p_style($content) {
 $output=str_replace_once('<p>', '<p class="first">', $content);
 return ($output);
}

Primer Paràgraf