@
feiyuanqiu 就像:
http://www.huging.com/?s=\*
和
http://www.huging.com/?s=*请问、这段代码可以优化吗?
顺手贴一下代码:
<?php newtheme_switch('header.php') ?>
<div id="content">
<div class="goods<?php if(is_mobile()){echo ' ajax';}else{ ajax_ias();} ?>">
<?php if(have_posts()):query_posts($query_string .'&showposts='.newtheme_showposts());
echo '<p id="prompt">以下是为您搜索到的信息,如果没有您想要的,可尝试缩短或更换关键词。</p>';
while(have_posts()):the_post();
$title = get_the_title();
$keys = explode(" ",$s);
if ($s) {$title = preg_replace('/('.implode('|', $keys) .')/iu','<span style="color:#f40f40;text-decoration:underline;">\0</span>',$title);} ?>
<article>
<a class="thumbnail" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"<?php target_blank() ?>>
<?php newtheme_thumbnail() ?>
</a>
<?php if(newtheme_cn('links','link_url')):
if(newtheme_cn('goods','widget')): ?>
<span class="ali_625"><a data-type="0" biz-itemid="<?php ali_goods_id() ?>" data-tmplid="625" data-rd="2" data-style="2" data-border="0" href="#"></a></span>
<?php else : ?>
<a class="buy" href="<?php links_url() ?>" rel="nofollow noopener" target="_blank"><?php links_title() ?></a>
<?php endif;endif ?>
<h2>
<a href="<?php the_permalink() ?>" title="详细阅读:<?php the_title() ?>"<?php target_blank() ?>><?php echo $title ?></a><?php if(newtheme_cn('goods','subhead')):?><span class="subhead"><?php echo newtheme_cn('goods','subhead') ?></span><?php endif ?>
</h2>
<p class="info">
<time class="icon-time"><?php the_time( get_option('date_format') ) ?></time>
<span class="cat icon-star"><?php newtheme_ie('分类:');the_category('、') ?></span>
<?php newtheme_like('<span class="icon-like"></span>',' 喜欢') ?>
</p>
<p class="desc"><?php echo newtheme_excerpt(120) ?> <a href="<?php the_permalink() ?>" class="readmore" title="详细阅读:<?php the_title() ?>"<?php target_blank() ?>>查看全文</a></p>
</article>
<?php endwhile; else:
echo '<p id="prompt">非常抱歉,无法搜索到您可能需要的信息,我们为您随机推荐了以下文章。</p>';
$cat = get_option('cat_limit');
$showposts = newtheme_showposts();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'order' => DESC,
'orderby' => 'rand',
'cat' => $cat,
'post__not_in' => get_option('sticky_posts'),
'showposts' => $showposts,
'paged' => $paged
);
query_posts($args);
while (have_posts()) : the_post();
if(is_mobile()){
include('mobile/goods.php');
}else{
include('pc/goods.php');
}
endwhile;wp_reset_query();
endif;
?>
<?php newtheme_paging() ?>
</div>
</div>
<?php newtheme_switch('footer.php') ?>