Forums

Ordering custom posts within a customized loop (3 posts)

  1. gluethje
    Member
    Posted 9 months ago #

    OK, let's see if I can efficiently explain my setup...

    First, I'm not super handy with PHP. I can see what's going on, tweak things I find to suit my needs, and I'm pretty good at not screwing things up, but I can't really write it on my own.

    I am using the Custom Post Type UI plugin to to create custom posts and taxonomies to organize products by product type.

    I'm using a custom page template to display a grid of product boxes on product category pages. Example.
    This page template looks like this:

    [for more than 10 lines of code, please use the http://pastebin.com/ - see http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    I need a way for the client easily reorder these product boxes. I'm trying to use the Postmash plugin, and it does seem to order the way the posts show up in the admin panel, but I can't seem to get it to apply on this custom page. Adding 'order' => 'ASC' in the query_posts() array did change the order to ascending, but I can get the Postmash filter's order to apply

    As I said, the necessity is to have the client be able to easily re-order these things after I'm done and hand the site over.

    I hope I've explained this well enough without getting to complicated...

  2. gluethje
    Member
    Posted 9 months ago #

    Oops forgot about the code limit. Here is the pastebin link:
    http://pastebin.com/uTqR1ANs

  3. gluethje
    Member
    Posted 9 months ago #

    Solved this one on my own. Kind of a "duh" moment, but then I'm a PHP n00b, so I feel pretty good about it.

    My little loop went something like this (I wish I could say I wrote it all myself. But it is based on a few different things I found here and there, and I have significantly altered it):

    <?php if ( (is_page('Hoof Boots & Accessories')) ){
                   $args = array(
                      'post_type'                  => 'products',
                      'product_category'     => 'Hoof Boots',
                      'order'                        => 'ASC'
                     );
    
                    query_posts($args);
                    while (have_posts()) {
                    the_post();
     ?>

    And I figured out all I had to do was change 'order' => 'ASC' to 'orderby' => 'menu_order'.

    Bam!

    Hope it helps someone else...

Reply

You must log in to post.

About this Topic

Tags

No tags yet.