Hi guys,
Long time troll. First time poster. Apologies if there is a thread for this. I'm working on a website for a friend and trying to get the product pages to sort alphabetically. I've tried using codes provided in other threads but to no avail.
http://kobrashredders.com.au/scec-endorsed-high-security-shredders/paper/
I want these products to sort alphabetically in ascending order (I.E: 240, 260, 300, 400, Cyclone, etc).
<?php
function getParents($id) {
global $wpdb;
$posts_table = $wpdb->prefix . "posts";
$parent_id = $wpdb->get_var("SELECT post_parent FROM $posts_table WHERE ID=$id");
if($parent_id == 0) return '';
$parent = get_post($parent_id);
return getParents($parent_id) . '<a href="'. get_permalink($parent_id) .
"\" title=\"$parent->post_title\">$parent->post_title</a> > ";
}
?>
<!-- LOOP -->
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php global $post; echo getParents($post->ID); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<!-- Display Subpages & Products -->
<ul id="productlist">
<?php
$children = get_children("post_type=page&post_parent=$post->ID&order=ASC");
foreach ($children as $child):
?>
<li>
<a href="<?php echo get_permalink($child->ID) ?>" title="<?php echo $child->post_title ?>">
<img src="<?php echo get_post_meta($child->ID, "Product Image", true) ?>" />
<span><?php echo $child->post_title ?></span></a>
</li>
<?php endforeach; ?>
</ul>
<?php endwhile; ?>
<?php else : ?>
Any help would be much appreciated.