I have an issue here that I just can't wrap my head around. Let me jump right into it:
Basically I have a site that has 4 order options;
-Name Ascending -Name Descending -Price Ascending -Price Descending
Getting it to order by "title" was easy enough after I fixed some issues. Basically just did this..
<?php $order = isset($_GET['order']) ? $_GET['order'] : "ASC"; $sort_by_title = isset($_GET['sort']) ? $_GET['sort'] : "title"; ?>
<?php $args["orderby"] = $sort_by_title; $args["order"] = $order; ?>
<a id="name-ascending" href="?order=ASC">Name Ascending</a> <a id="name-descending" href="?order=DESC">Name Descending</a>
Now the price field is a custom field, and it's easy enough to sort by price if I replaced
$args["orderby"] = $sort_by_title;
$args["orderby"] = $custom_field_name;
It'll sort it by price and there's no issue there. The issue is figuring out how to figure out what the user clicks and determining what it should now be ordered by.
If needed, my full $args is
$args = array('post_type' => 'model-pricing', 'posts_per_page' => 5, 'meta_key' => 'Community', 'meta_value' => $community_choice, 'paged' => $paged); $args["orderby"] = $sort_by_title; $args["order"] = $order;
I'd really appreciate some help with this one guys, even some insightful thoughts on how I might tackle this issue. Thanks!