Trying to figure out how I can output my posts based on category title (aâz) and secondly, the title of the posts within the category:
A CATEGORY
â A post beginning with a
â Because I want to be output second
â Come on, and output me already
B CATEGORY
â Another post beginning with a
â Bother, can’t come up with another title on B
â I guess you get the point
How do I achieve this?
To get them broken down by Category, you need to loop through the list of categories and then query on each category:
I think do you mean
GROUP Post
by category/taxonomyNOT SORT
.Here, Is a code to
GROUP
bycategory/taxonomy
$terms = get_terms( 'my_cat_name' );
Here,
cat_name
name is the name of taxonomy, When you register it like this: e.g.Use it in
Query
e.g.:Complete code:
Expanding on Maheshwaghmare’s work;
You can use
orderby
parameter for a newwp_query
instance:Soo for every category use a separate instance.
More information here: http://codex.wordpress.org/Class_Reference/WP_Query