Skip to main content
added 15 characters in body
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question:

A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question:

What's the best approach? How would I make a meta_querymeta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit:

Or would it be an option to use two wp_queriesinstances of WP_Query, one for the posts with custom-field-1 value = '1' and one for those with value 0 ?

I know this "order by multiple custom field values" has been discussed a lot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question:

A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question:

What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit:

Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1' and one for those with value 0 ?

I know this "order by multiple custom field values" has been discussed a lot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question:

A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question:

What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit:

Or would it be an option to use two instances of WP_Query, one for the posts with custom-field-1 value = '1' and one for those with value 0 ?

I know this "order by multiple custom field values" has been discussed a lot here, but I did not find a similar question I could adapt when I was searching the site before.

Tweeted twitter.com/#!/StackWordPress/status/524240351943331840
Better formatting
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

I have created a custom post type that I want to order by

  1. custom-field-1custom-field-1, which is boolean so its value is either '1'1 or '0'0, in DESCDESC order (1 to 0)
  2. custom-field-2custom-field-2, which contains text and is supposed to be ordered ASCASC (A to Z)

First Question: 

A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question: What's

What's the best approach? How would I make a meta_query order the posts by custom-field-1custom-field-1 in descending order and then by custom-field-2custom-field-2 in ascending order?

Edit: 

Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1'custom-field-1 value = '1' and one for those with value '0' 0 ?

I know this "order by multiple custom field values" has been discussed alota lot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either '1' or '0', in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question: A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question: What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit: Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1' and one for those with value '0' ?

I know this "order by multiple custom field values" has been discussed alot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question: 

A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question:

What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit: 

Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1' and one for those with value 0 ?

I know this "order by multiple custom field values" has been discussed a lot here, but I did not find a similar question I could adapt when I was searching the site before.

added 146 characters in body
Source Link
okiedokey
  • 181
  • 3
  • 15

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either '1' or '0', in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question: A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question: What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit: Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1' and one for those with value '0' ?

I know this "order by multiple custom field values" has been discussed alot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either '1' or '0', in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question: A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question: What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

I know this "order by multiple custom field values" has been discussed alot here, but I did not find a similar question I could adapt when I was searching the site before.

I have created a custom post type that I want to order by

  1. custom-field-1, which is boolean so its value is either '1' or '0', in DESC order (1 to 0)
  2. custom-field-2, which contains text and is supposed to be ordered ASC (A to Z)

First Question: A more powerful ORDERBY-parameter was introduced in WordPress 4.0. Can this be made using the new ORDERBY functionality?

If not, second Question: What's the best approach? How would I make a meta_query order the posts by custom-field-1 in descending order and then by custom-field-2 in ascending order?

Edit: Or would it be an option to use two wp_queries, one for the posts with custom-field-1 value = '1' and one for those with value '0' ?

I know this "order by multiple custom field values" has been discussed alot here, but I did not find a similar question I could adapt when I was searching the site before.

Source Link
okiedokey
  • 181
  • 3
  • 15
Loading