Hello,
I’m not sure if you intended it, but the [is] shortcode checks the current user’s role, not post taxonomy. It’s used like this:
[is role="subscriber"]
..This will only display for users with role "subscriber".
[/is]
For the loop, I checked and it should be possible to specify both category and a custom taxonomy at the same time.
[loop type="post" category="latest-news" taxonomy=”role” term=”general-public,subscriber”]
...
[/loop]
This should display posts in the category latest-news, which also has either general-public or subscriber as a term in the taxonomy role.
It might just be a typing mistake, I notice in your code that the [loop] is not closed with [/loop], and there are two starting brackets: [[field].
Another thing that could help is to look in the admin panel under Dashboard -> Content. There you can find taxonomies with list of term slugs to use.
Hi, okay, thank you for fixing the syntax of my code :))
I’ve discovered that it’s returning posts from both the category “latest-news” OR the taxonomy=”roles”. I need it bring back posts that have BOTH “latest-news” and the defined “roles”. I need the compare to be “and”. In fact, I tried adding compare=”and” both before the word “taxonomy” and after the list of terms. Neither worked.
Also, I just discovered that you’ve created special terms for the plugin WCK. I’ve used WCK to create the custom taxonomy, if that makes a difference here.
This is what I have:
[is logout] [loop type=”post” category=”latest-news” taxonomy=”roles” term=”general-public”][field image image_class=”alignleft”][br][field title-link] [field excerpt][br][/loop][/is]
[is role=”subscriber”][loop type=”post” category=”latest-news” taxonomy=”roles” term=”general-public,subscriber”][field image image_class=”alignleft”][br][field title-link] [field excerpt][br][/loop][/is]
[is role=”contributor”][loop type=”post” category=”latest-news” taxonomy=”roles” term=”general-public,subscriber,steering-committee”][field image image_class=”alignleft”][br][field title-link] [field excerpt][br][/loop][/is]
[is role=”editor,author,administrator”][loop type=”post” category=”latest-news” taxonomy=”roles” term=”general-public,subscriber,steering-committee,mders-staff”][field image image_class=”alignleft”][br][field title-link] [field excerpt][br][/loop][/is][br]
Ooh, I see, so you did intend to check both current user role and get posts based on taxonomy roles.
posts that have BOTH “latest-news” and the defined “roles”
For this situation, I think it can be written as:
[loop type=post taxonomy=category term=latest-news relation=and taxonomy_2=roles term_2=general-public]
The parameter relation defines the relation between two taxonomies. By default, relation=or.
The parameter compare defines the comparison between a taxonomy and its term. By default, compare=equal.
(I recently found that “quotes” are only necessary if there’s a space in the parameter value. So omitting them makes the above query a little shorter..!)