admin管理员组文章数量:1025522
I have parent category is Game cat_id=42
. Child categories are : acrade, causual,....
I want show a top game module in mainpage template, it will show 10 sticky post from game category.
This my code :
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
query_posts( $args );
?>
I have parent category is Game cat_id=42
. Child categories are : acrade, causual,....
I want show a top game module in mainpage template, it will show 10 sticky post from game category.
This my code :
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
query_posts( $args );
?>
Share
Improve this question
edited Dec 13, 2013 at 10:57
Rahil Wazir
1,03116 silver badges26 bronze badges
asked Dec 13, 2013 at 9:49
user43862user43862
335 bronze badges
1 Answer
Reset to default 2Use the below code in the mainpage template to show the sticky posts.
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
The above will print the title of the sticky posts
I have parent category is Game cat_id=42
. Child categories are : acrade, causual,....
I want show a top game module in mainpage template, it will show 10 sticky post from game category.
This my code :
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
query_posts( $args );
?>
I have parent category is Game cat_id=42
. Child categories are : acrade, causual,....
I want show a top game module in mainpage template, it will show 10 sticky post from game category.
This my code :
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
query_posts( $args );
?>
Share
Improve this question
edited Dec 13, 2013 at 10:57
Rahil Wazir
1,03116 silver badges26 bronze badges
asked Dec 13, 2013 at 9:49
user43862user43862
335 bronze badges
1 Answer
Reset to default 2Use the below code in the mainpage template to show the sticky posts.
<?php
$args = array(
'cat' => 42,
'posts_per_page' => 10,
'post__in' => get_option( 'sticky_posts' ),
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
The above will print the title of the sticky posts
本文标签: categoriesGet sticky post from category
版权声明:本文标题:categories - Get sticky post from category? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745635447a2160419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论