你可以使用add_action(loop_start,smtg)或add_action(loop_end,smtg)或apply_filters('the_content', $content);
喜欢:
<?php
$content = apply_filters('the_content', $content);
$content = do_your_stuff;
?>
这真的取决于你想做什么......
在这里查看更多:http://codex.wordpress.org/Plugin_API/Action_Reference
所有“上 - 下 - 重叠”都不是真正相关的 - 它们是特定于 CSS 的..
但是,如果您真的想这样做 - 您可以随时在内容上使用 REGEX...
或其他方法 - 例如:
function k99_replace_content(){
//get the content
$content= get_the_content(); //get the content as a variable
// where we want to cut ??
// by length ??
$full_length= STRLEN($content);
$cutting_point = ($full_length/ 2);
// regex ??
//do regex stuff here ..
// clip off the first part - if we choose by length
$firstpart = SUBSTR($content, 0, $cutting_point);
// ending '<br>'
$end_point = STRRPOS($firstpart, '<br>');
// add whatever
return SUBSTR($content, 0, $end_point) . "<div>put whatever you want>/div>" . SUBSTR($content, $end_point);
}
add_filter('the_content', 'k99_replace_content');
或最后一个选项,使用@IanB 建议的方法和其中一种方法 - 并通过过滤器包含..