When inserting a post in wordpress, I have the taxonomy 'group' with terms 'pharmacies, grocery stores, snack bars ...', which are the groups, since I already have clients for these groups. What I need is that, when you log in to have restricted access in the client area, wordpress checks to see if you have news for the group whose client is a part and, if so, show it along with the post specifically for the client. >
To show customer-targeted news I already have, I just can not do this group verification.
/*
Eu tenho o ID do CLIENTE na $_GET.
Tenho que buscar os grupos que o cliente participa
Checar se algum desses grupos tem vinculo com a noticia
*/
$meta_query[] = array(
'key' => 'clientes',
'value' => $_GET['id'],
'compare' => '='
);
$tax_query[] = array(
'taxonomy' => 'grupo'
);
$args = array(
array(
'post_type' => 'noticias'
,'meta_query' => $meta_query
)
);
$tmp = new WP_Query($args);
if(!$tmp->have_posts()){
echo 'não tem notícias no momento';
return;
}
while ($tmp->have_posts()){
$tmp->the_post();
echo get_the_title().'<br>';
}
Note: The client is inserted into the post_type 'clients'. In this post_type I have the fields email, password and groups are listed in the form of taxonomy to be able to link the client to the group.