I’d want to edit the content of one of my posts using this way, but it’s not working.
Does this filter affect the php output or the raw php file?
add_filter( 'the_content', 'multiple_string_replacements');
function multiple_string_replacements ( $contentt ) {
if ( is_single('15467') && in_the_loop() && is_main_query() ) {
$condition = true;
if($condition){
$urlsdothejob = "link.com";
$text = array(
"$variable1" => "$urlsdothejob",
"$variable2" => "$urlsdothejob",
);
$contentt = str_ireplace(array_keys( $text ), $text, $contentt);
};
}
return $contentt;
}
2
Answers
If you know the conditions that you’re looking for, you should be able to write an
IF
statement to match.Can you give an example of what you’re trying to do? It’s hard to understand the request with such little information.
Try like this hope its working for you.