如何在wordpress函数中用两个字符串之间的变量替换wp-post内容?

时间:2018-05-15 07:58:34

标签: php wordpress wordpress-theming

我想要一个wordpress函数来替换iframe src,例如:(http://my1stembed.tld/ variablestring .html)到(http://my2ndembed.tld/ variablestring .html) -in wordpress发布内容与变量。我该怎么做呢。我需要这样的功能

function replace_content($content)
{
$content = str_replace('http://my1stembed.tld/', 'http://my2ndembed.tld/',$content);
return $content;
}
add_filter('the_content','replace_content');

上述函数仅将固定的eg:(http://my1stembed.tld/)字符串替换为(http://my2ndembed.tld/)而不是变量。我是wordpress的新手并且不知道。任何帮助都非常感谢。

<iframe src="http://my1stembed.tld/embed/variablefilename/" width="640" height="360" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe>

<iframe src="http://my2ndembed.tld/embed/variablefilename/" width="640" height="360" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe>

0 个答案:

没有答案