Replace only the first CSS class

Question

I’m trying to replace the "thumb-w" CSS class with "thumb-w1", just the first time.
This is the starting function:

function start_modify_html() {
   ob_start();
}
function end_modify_html() {
   $html = ob_get_clean();
   $html = str_replace( 'thumb-w', 'thumb-w 1', $html);
   echo $html;
}
add_action( 'wp_head', 'start_modify_html' );
add_action( 'wp_footer', 'end_modify_html' );

I tried entering "1" in the str_replace in this way:

$html = str_replace( 'thumb-w', 'thumb-w 1', $html);

but it doesn’t seem to work.
Can you help me?
Thanks

0
marcorroma 2 months 0 Answers 13 views 0

Leave an answer