You could use a Wordpress filter callback function. In your theme's directory, locate or create a file called functions.php
and add the following in:
<?php
add_filter("the_content", "plugin_myContentFilter");
function plugin_myContentFilter($content)
{
// Take the existing content and return a subset of it
return substr($content, 0, 300);
}
?>
The plugin_myContentFilter()
is a function you provide that will be called each time you request the content of a post type like posts/pages via the_content()
. It provides you with the content as an input, and will use whatever you return from the function for subsequent output or other filter functions.
You can also use add_filter()
for other functions like the_excerpt()
to provide a callback function whenever the excerpt is requested.
See the Wordpress filter reference docs for more details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…