with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name;
how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
with this code
$wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle);
I exchange words in one of my loops.
Now I am trying to change a word that is called with echo $term->name;
how do I implement that? I tried
<?php
$wptitle = str_replace(array(' .echo ($term->name;)'), '', $wptitle);
?>
but its obviously not working :-(
Share Improve this question edited Nov 22, 2018 at 22:56 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 21, 2018 at 14:12 joloshopjoloshop 211 silver badge8 bronze badges 5 |1 Answer
Reset to default 1The PHP echo
language construct that outputs the parameters passed. You don't want to do that in the middle of str_replace
. To replace $term->name with an empty string, use:
$wptitle = str_replace( $term->name, '', $wptitle );
Then when you want to print it, use:
echo $wptitle;
.echo ($term->name;)
in an array? – Gufran Hasan Commented Nov 21, 2018 at 14:18echo $term->name;
occurs? (couple of lines before and after so we have context) – kero Commented Nov 21, 2018 at 14:19$wptitle = str_replace($term->name, 'neuer Text', $wptitle);
(also, this isn't a wordpress question. this is a PHP question) – ChrisG Commented Nov 21, 2018 at 14:29