I am writing a "What's On" page so guests can enter details of events in their area.
To help, I have added a new Taxonomy called 'town' in which I have added a list of towns so the user can select a town relevant to their post. I am also coding a sidebar entry system so the user can just enter information while looking at all posts and not having to go onto a new screen. (I don't allow users into the dashboard so they have to enter details from the front end).
To lists all the entries for the 'town' taxonomy I am using:
$terms = get_terms("town");
$count = count($terms);
if ( $count > 0 ){
echo "
<ul>";
foreach ( $terms as $term ) {
echo "
<li>" . $term->name . "</li>
"; }
echo "</ul>
"; }
[Please post code snippets between backticks or use the code button.]
However this only returns taxonomy terms for existing posts. I want to list all taxonomies so the users can select from a lists - Even if there are no events in their town.
I've spent ages trying to find the answer to this but all the solutions only show taxonomy entries for any post which has a taxonomy associated with it. Any help would be great. I'm still pretty new to WordPress but am liking every minute of it.
Thanks,
Paul