开发者

WordPress control both post order and number of posts in category.php

I have these two snippets, the first for displaying a customized post order via postMash:

<?php
$wp_query->set('orderby', 'menu_order');
$wp_query->set('order', 'ASC');
$wp_query->get_posts();
?>
<?php get_posts("orderby=menu_order&order=ASC"); ?>

and the second for retrieving a custom number of posts.

<?php
$myPosts = new WP_Query()开发者_开发百科;
$myPosts->query('showposts=50');
while ($myPosts->have_posts()) : $myPosts->the_post();
?>

How do I combine them into one category.php ?

Here is my category.php with just the first snippet:

http://pastebin.com/J8L7crNL


I haven't used postMash before, but if I understand its documentation correctly, you can just compose your query with get_posts like this:

<?php  
    $args = array( 'numberposts' => 50, 'order'=> 'ASC', 'orderby' => 'menu_order' );
    $my_posts = get_posts( $args );
    foreach ($my_posts as $post) :  setup_postdata($post); 
        //loop action
    endforeach;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜