4
I have a site session (Wordpress) where I add partners according to the category using Custom Post Type. It is a ballroom site. Each custom post type category represents a branch. Ex of the categories: Buffet, Photographers, Etc.
So far so good. It’s working OK.
It has a field created as a custom field called "wpcf-priority-partner" and I want it to work like this: If it is equal to 0, order the partners in normal alphabetical order. If the value is non-zero (from 1 to 9) it has to sort these above the partners listed with 0 and in descending priority order. 9 above 8, 8 above 7 and so on.
The intention is that when a partner pays to stay in evidence it goes to the top of the list according to the priority (from 1 to 9) and those who stay set as 0 are in alphabetical order below those who are priority.
Ps.: I am a designer, I venture into orelhada PHP. But there are times I have to ask for a HELP.
What I did is listing the priorities correctly at the top of the list in descending order from 9 to 1, but those with priority 0 are listed in descending alphabetical order as well (From Z to A)but I want these to be listed alphabetically from A to Z and below the priority.
How to make an order=> 'ASC' by sorting by title only for those with the "wpcf-priority-partner" field listed as 0?
Here’s what I did:
<?php
$args=array(
'post_type' => 'parceiros',
'posts_per_page' => 150,
'meta_key' => 'wpcf-prioridade-parceiro',
'orderby' => 'wpcf-prioridade-parceiro',
'order' => 'ASC');
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post();
?>
It worked perfectly. I only had to customize the way the result was shown, because the partners shown with priority other than 0 need to be highlighted using a CSS class different from the others. Thank you so much for your help. Congratulations on your efficiency and patience in helping. I think it will be useful for many people, because I haven’t found any article about it. !
– koelho86