傻大憨

wordpress调用随机文章和随机推荐文章

wordpress调用随机文章的代码如下:

<?php
$query = array(
'post_type' => 'post',
'orderby' => 'rand'
);
$posts = new WP_Query( $query );
if ( $posts->have_posts() ) {
while( $posts->have_posts() ) :
$posts->the_post();
the_content();
endwhile;
}
wp_reset_query();
?>

wordpress随机调用置顶推荐的文章代码:

<?php
//获取置顶文章的ID串
$rand_id = get_option( 'sticky_posts' );
$query = array(
'post__in' => $rand_id,
'post_type' => 'post',
'orderyby' => 'rand',
'numberposts' => 2
);
$posts = new WP_Query( $query );
if ( $posts->have_posts() ) {
while( $posts->have_posts() ) :
$posts->the_post();
the_content();
endwhile;
}
wp_reset_query();
?>
Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

模板之家mymoban

通过模板之家,用户可以找到适合各种需求的模板,无论是个人项目还是商业用途,都能找到合适的解决方案。

wordpress子页面获取父页面的标题和链接

wordpress子页面获取父页面的标题和链接

single文章页获取父分类别名

将下面这段代码添加到single.php中需要显示父分类别名的位置,就可以显示出父分类的别名。

WordPress菜单函数wp_nav_menu各参数

在不同的位置调用不同的菜单,使用下面的这个代码

The best foreign trade website building company in Shenzhen

Waimaoyes is a company specializing in foreign trade website construction, mainly providing WordPress multilingual foreign trade small language website construction services.

WordPress外贸建站模板选择:关键因素与详细分析

在当今全球化的商业环境中,外贸建站已成为企业拓展国际市场、提升品牌形象、增强竞争力的关键手段。WordPress作为一款功能强大、易于使用的建站平台,受到了众多外贸企业的青睐。