每页只能执行一次WordPress快捷码
我已经写了下面的短代码,它对于所有密集型的目的都是有效的,但是它每页只工作一次。如果我多次尝试添加短代码,则在_content()中的短代码之后没有任何内容代码>被输出每页只能执行一次WordPress快捷码,wordpress,function,simple-html-dom,shortcode,Wordpress,Function,Simple Html Dom,Shortcode,我已经写了下面的短代码,它对于所有密集型的目的都是有效的,但是它每页只工作一次。如果我多次尝试添加短代码,则在_content()中的短代码之后没有任何内容被输出 add_shortcode('some_shortcode', 'some_shortcode'); function some_shortcode($atts, $content = null){ extract(shortcode_atts(array( "url" => '' ), $atts));
add_shortcode('some_shortcode', 'some_shortcode');
function some_shortcode($atts, $content = null){
extract(shortcode_atts(array(
"url" => ''
), $atts));
require_once get_parent_theme_file_path( '/simple_html_dom.php' );
$html = file_get_html($url);
foreach($html->find('div.matchbox') as $match) {
$item['time'] = $match->find('div.time', 0)->plaintext;
$matches[] = $item;
}
return '<hr><p>' . $url . '</p><p>' . $item['time'] . '</p>';
}
add_-shortcode('some_-shortcode','some_-shortcode');
函数的某些快捷码($atts,$content=null){
提取(短码)附件(数组)(
“url”=>“”
)美元(附件);;
需要一次获取父主题文件路径('/simple\u html\u dom.php');
$html=file\u get\u html($url);
foreach($html->find('div.matchbox')作为$match){
$item['time']=$match->find('div.time',0)->纯文本;
$matches[]=$item;
}
返回“
”.$url.”.$item['time'].”;
}
听起来第二个是致命错误。打开调试并尝试获取错误消息。而且,它是“出于所有的意图和目的”。听起来第二个是致命的错误。打开调试并尝试获取错误消息。而且,它是“为了所有的意图和目的”。