This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Sitemap post order

  • Creator
    Topic
  • #14327
    Mark Wiard
    Participant

    On this page:

    http://salidachamber.org/wp/salida-chamber-membership/

    I would like to make the individual business names/links to show in a random order. Now, they show in the order that I posted them. It seems like I should be able to use the orderby feature. When I use it in the query_posts line, it kills the category listing.

    Note that this is a custom template based on the sitemap template.

    If you can give me a direction on how to accomplish this, I can probably figure it out from there.

    Thank you,

    mark

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #14331
    Jason Bobich
    Keymaster

    Hello Mark,

    Sounds like you’re on the right track. You’d need to customize the query passed in.

    When I use it in the query_posts line, it kills the category listing.

    What specifically are you doing that’s killing it?

    #14338
    Mark Wiard
    Participant

    This is the code that I got from the sitemap template, work perfectly, except the businesses are not random order.

    <article id="post-”

    <?php edit_post_link( themeblvd_get_local( 'edit_page' ), '’, ” ); ?>
    The Salida Colorado Chamber of Commerce Membership

    cat_ID); ?>
    cat_name; ?>

    <a href="”>

    if I modify this line

    cat_ID); ?>
    to add the orderby
    cat_ID); ?>

    I get all the businesses listed under every category, and not random:
    http://salidachamber.org/wp/salida-chamber-membership/

    mark

    #14339
    Mark Wiard
    Participant

    Sorry that code did not work, trying again

    from your original sitemap template, I added the orderby

    <?php query_posts('cat=&orderby=rand'.$cat->cat_ID); ?>

    full loop code

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>
    	<div class="entry-content">
    		<?php rewind_posts(); ?> 
            <?php edit_post_link( themeblvd_get_local( 'edit_page' ), '<p class="edit-link clearfix">', '</p>' ); ?>
            <h1 class="entry-title">The Salida Colorado Chamber of Commerce Membership</h1> 
            <?php $cats = get_categories(); ?>
            <?php foreach ($cats as $cat) : ?>
            
                  <?php query_posts('cat=&orderby=rand'.$cat->cat_ID); ?>
                
                    <h2><?php echo $cat->cat_name; ?></h2>
                    <ul class="sitemap">
                        <?php while (have_posts()) : the_post(); ?> 
                        <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> 
                        <?php endwhile; wp_reset_query(); ?>
                    </ul>
                    
            <?php endforeach; ?>
    	</div><!-- .entry-content (end) -->
    </article>

    I get all the businesses listed under every category, and not random:

    http://salidachamber.org/wp/salida-chamber-membership/

    #14348
    Jason Bobich
    Keymaster

    Is this what you’re trying to do?

    <?php query_posts('cat='.$cat->cat_ID.'&orderby=rand'); ?>
    #14388
    Mark Wiard
    Participant

    Jason,
    This works perfectly, thank you.
    mark

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.