调用指定分类的最新10条
/调用指定分类27的最新10条

<?php
$args = array(
'post_type' => 'post', //自定义文章类型名称
'showposts' => 10, //输出的文章数量,这个可以是缺省值,不用设置
'orderby' => 'modified', //按更新时间排序
'tax_query' => array(
array(
'taxonomy' => 'circle',//自定义分类法名称
'terms' => 27 //id为64的分类。也可是多个分类array(12,64)
),
)
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();?>
<li>
<a href="<?php%20the_permalink()%20?>" target="_blank"><?php the_title(); ?></a>

</li>
<?php endwhile; wp_reset_query(); //重置query查询
} ?>

让搜索结果支持自定义内容模型:
//让搜索支持自定义文章类型

function searchAll( $query ) {
if ( $query->is_search ) { $query->set( 'post_type', array( 'post','forums', 'product' )); }
return $query;
}
add_filter( 'the_search_query', 'searchAll' );

调用指定搜索关键字(如沙县小吃)文章list:

<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
's'=>'沙县小吃',
'showposts' => 10,
'paged' => $paged
);
query_posts( $args );
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<p><a href="<?php%20the_permalink()%20?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
wp_reset_postdata();
endif;
?>

调用指定关键词调用list:

<?php the_content(); ?>
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
's'=>'福建',
'showposts' => 10,
'paged' => $paged
);
query_posts( $args );
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<p><a href="<?php%20the_permalink()%20?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
wp_reset_postdata();
endif;
?>

指定文章的tag id 调用列表list:

<?php
$args=array(
'tag_id' => 16,//指定id
'posts_per_page' => 5,//每页显示多少
'orderby' => 'rand', //按随机排序
);
query_posts($args);
if(have_posts()) : while (have_posts()) : the_post(); ?>
<li style="font-weight: bold;">
<a href="<?php%20the_permalink()%20?>" target="_blank"><?php the_title(); ?></a>
<span class="time"><?php the_time('Y年n月j日'); ?></span>
</li>

<?php endwhile; endif; wp_reset_query();?>

指定频道cat=7随机10条list:

<?php query_posts('post_type=post&cat=7&showposts=10&orderby=rand'); ?>
<?php while (have_posts()) : the_post(); ?>

<li><a href="<?php%20the_permalink()%20?>" target="_blank"><?php the_title(); ?></a></li>
<?php endwhile; ?>

基于wpjam缩略图插件的调用cat=11最新修改的12条图文:

<?php $cat = get_the_category();
foreach($cat as $key=>$category) {
$catid = $category->term_id;
}
$args = array('orderby' => 'modified','showposts' => 12,'cat' => 11 );
$query_posts = new WP_Query();
$query_posts->query($args);
while ($query_posts->have_posts()) : $query_posts->the_post();
?>
<div class="col-md-3 product-item mt30">
<a href="<?php%20the_permalink()%20?>" target="_blank" class="text-center center-block">
<?php if(wpjam_has_post_thumbnail()){?>

<div class="entry-thumb">
<a href="<?php%20the_permalink()%20?>" title="<?php the_title_attribute(); ?>"><?php wpjam_post_thumbnail([260,260],$crop=1);?></a>
</div>
<?php } ?>
<h3><?php the_title(); ?></h3>
</a>
</div>

<?php endwhile;
?>
<?php wp_reset_query();
?>
</div>
<?php endif; ?>

针对不同浏览器显示不同内容,比如微信公众号内显示微信公众号二维码,普通浏览器打开百度小程序二维码:

<?php $useragent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($useragent, 'MicroMessenger') === false) {
echo "<img src="https://www.cliya.com/" alt="独立站谷歌优化" style="float:right;width:100px">";
} else {
echo "
<img src="https://www.cliya.com/" alt="独立站谷歌优化" style="float:right;width:100px">

";
} ?>