Onebrightlight
Member
Posted 3 years ago #
I'm looking to add links to a section that link to attorneys who match a custom field name/value. In this case, it's a value of the meta_key being something like "tax_planning" and the meta_value being "on". How would I insert that into a link so that I return a series of all pages that have this combination?
Thanks for your help!
Look to use the template tag, query_posts():
query_posts('meta_key=tax_planning&meta_value=on&post_type=page');
Onebrightlight
Member
Posted 3 years ago #
Thanks for the help!
When I put it into the place of the link however, the page ends up not loading, though no error message is given. It just seems to keep trying to access the page. Am I forming the link incorrectly?
<a href="<?php query_posts('meta_key=tax_planning&meta_value=on&post_type=page'); ?>">Commercial Litigation & Dispute Resolution</a>
That query_posts will return a list of posts meeting that criteria. You will need to put that code, along with a loop, in the necessary template.
Related:
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
Onebrightlight
Member
Posted 3 years ago #
Right. I think I've got that here, but I could of course be wrong. I think it's set up in the loop currently this way:
http://pastie.org/private/y9oaqffkjbqilsi3tglq
Basically when I click the link, I'd like to generate a page that lists everyone matching these values. That or a dropdown box below the DL would work too.
Sorry if I'm making this too confusing. The client ended up requesting these features MUCH after the fact.