Support » Fixing WordPress » Sort by custom field

  • I tried to use Mike Smullin’s “Sort Categories By Title” plugin to sort posts according to the value of the custom field “parag” which is a 4 digit number and modified the code to this:

    function sort_categories_by_title($x) {
    	if(in_category(4)) {
    		$x->query_vars['orderby'] = 'parag';
    		$x->query_vars['order'] = 'ASC';

    I want to sort them only when displaying one category (#4 in this case) and then sorted by “parag” whatever value it has.

    Help please!

    ps. I tried is_category, in_category and a different custom value field but none of this seems to work. It also doesn’t seem as if I have to call the function since it is included in the action call.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Unfortunately i don’t know, but a forum guy named Kafkaesqui helped me a lot with custom fields in the past, I think he could explain how, if he comes on here.






    I’m using the plugin above, but have a small problem. I’m using a custom field call ‘pris’ that contains any number for example 354.

    Now i want to sort the post by that number, starting with the lowest. Couldn’t get the plugin to sort properly, any suggestions on how to fix that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort by custom field’ is closed to new replies.