WordPress.org

Ready to get started?Download WordPress

Forums

displaying posts using the order attribute (6 posts)

  1. cokeyblokey
    Member
    Posted 2 years ago #

    I have a custom post type which includes the 'Order' attribute. I've searched for a solution to get WP to actually use the 'order' value to display the posts (by default they are displayed in date order).

    I can see from the codex that I need to add the following to my loop:
    query_posts( array('orderby'=>'menu_order' ) );

    But unfortunately I just can't get it working. I'm using a modified loop from Twenty Ten theme. Where exactly should I be placing the above code?

  2. justingreerbbi
    Member
    Posted 2 years ago #

    You have to tell it how to order as well;

    query_posts( array('orderby'=>'menu_order','order'=>'ASC' ) );

  3. cokeyblokey
    Member
    Posted 2 years ago #

    Thanks justingreerbbi but I still can't get it working. Where exactly in the loop should the code go?

  4. cokeyblokey
    Member
    Posted 2 years ago #

    this is driving me insane - no matter what I do I can't get it working. I can't get the posts to display via their order attribute, nor (as an alternative) can I get them to display by date, with oldest at top. Nothing works.

    ...anyone?

  5. cokeyblokey
    Member
    Posted 2 years ago #

    By putting this in my category template just before the loop, I can now get posts to display using the order attribute:

    query_posts( array('orderby'=>'menu_order','order'=>'ASC' ) );

    BUT - it displays the entire posts instead of just the excerpts. How do I get the excerpts back???

  6. cokeyblokey
    Member
    Posted 2 years ago #

    Finally, fixed it!

    I changed some code in the loop, enabling me to display excerpts when using query_posts

    I changed the following within the "entry-content" div:

    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'BTC' ) ); ?>

    replaced with:

    <?php the_excerpt(); ?>

    (please note I'm using a blank theme from blankthemes.com/ so your loop may differ).

    I really hope my hours of trial and error can be of benefit to others here.

Topic Closed

This topic has been closed to new replies.

About this Topic