我已经为主题定义了quote post格式:
// Add post-formats for theme
add_theme_support( 'post-formats', array(
'quote',
) );在此之后,我想显示内容的引号。为此,我想使用preg_match_all函数搜索
Hello World.
if( $format == 'quote' ) {
$content = apply_filters( 'the_content', get_the_content() );
preg_match( '//', $content, $matches );
}但这是行不通的。我想找到区块引号标签,并在这个标签中显示内容。
发布于 2019-05-21 13:25:36
元字符.匹配除换行符以外的任何字符.如果在引号中有新行,请尝试如下:
preg_match_all( '#([\s\S]*?)#', $content, $matches );Escape序列:
\s-任何空格字符\S-任何不是空格字符的字符
发布于 2019-05-21 11:59:03
尝试这段代码,如果有任何带有块引号的类,那么添加以下代码:
preg_match_all( '/(.*?)<\/blockquote>/', $content, $matches );https://wordpress.stackexchange.com/questions/338369
复制相似问题