我有生成帖子列表的短代码,但帖子会自动包含在<pre>
标签中,我不确定如何删除它们。例如:
<pre><li><a href=''><img src=''></a></li></li><pre>
这是短代码:
[loop the_query="tag=news"]
这是功能:
function custom_query_shortcode($atts) {
extract(shortcode_atts(array(
"the_query" => ''
), $atts));
$the_query = preg_replace('~�*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $the_query);
$the_query = preg_replace('~�*([0-9]+);~e', 'chr(\\1)', $the_query);
query_posts($the_query);
$output = '';
$temp_title = '';
$temp_link = '';
$temp_thumb = '';
if (have_posts()) : while (have_posts()) : the_post();
$temp_title = get_the_title($post->ID);
$temp_link = get_permalink($post->ID);
$temp_thumb = the_post_thumbnail( 'side-thumb' );
$output .= "<li><a href='$temp_link'>$temp_title <img src='$temp_thumb'></a></li>";
endwhile; else:
$output .= "nothing found.";
endif;
wp_reset_query();
return $output;
}
add_shortcode("loop", "custom_query_shortcode");
答案 0 :(得分:1)
我想看看以下内容: