Hi, please, I need some help.
I Have a user checkboxes custom field registered to use a Taxomony and is set to $Single= false. So I can check as many as I want.
I use this taxonomy also in my custom post type where my client can check one or many tags for each post.
So, what I need is to query all posts that has the same tags for each user. I have the code below:
if ( function_exists( 'slt_cf_register_box') )
add_action( 'init', 'register_my_custom_fields' );
function register_my_custom_fields() {
slt_cf_register_box( array(
'type' => 'post',
'title' => 'Dados do Arquivo',
'id' => 'dados-arquivo',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'ad_arquivorestrito',
'label' => 'Selecione o Arquivo',
'type' => 'file',
'file_button_label' => 'Selecionar arquivo',
'scope' => array( 'ad_arearestrita' ),
'capabilities' => array( 'edit_posts' )
)
)
));
slt_cf_register_box( array(
'type' => 'user',
'title' => 'Acesso as ConcessionĂ¡rias',
'id' => 'acesso-concessionaria',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'ad_acessoconcessionaria',
'label' => 'Acesso a:',
'type' => 'checkboxes',
'multiple' => true,
'options_type' => 'terms',
'options_query' => array( 'taxonomies' => 'ad_concessionaria', 'hide_empty' => false ),
'single' => false,
'scope' => array( 'administrator', 'admin', 'concessionaria', 'editor' ),
'capabilities' => array( 'edit_users' )
)
)
));
}
That's working fine! I have a checkboxes in my User Profile with all tags I created in the Taxonomy "ad_concessionaria".
Now I have the query below:
<?php
$args = array(
'post_type' => 'ad_arearestrita',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'ad_concessionaria',
'field' => 'id',
'terms' => $current_user->_slt_ad_acessoconcessionaria
)
)
);
$query = new WP_Query( $args );
while($query->have_posts()) : $query->the_post();
?>
That's working fine, but is retrieving just one post, because is getting just ONE "term" from my User Custom Field.......
I can't find a way to retrieve an Array of the values, since I use Checkboxes and I can have many tags in this field.....
Can you help me please??? How can I get an ARRAY of values to use in this Query?
http://wordpress.org/extend/plugins/developers-custom-fields/