[Resolved] How to insert page title into query_posts with custom fields
I am trying to work out how to create the code on my page.php template so that when I open a page (eg with the title ‘Spain’), all posts that have a custom field with a key of ‘country’ and the value of ‘Spain’ will show.
I have figured out that I need to insert:
<?php query_posts(‘meta_key=Country&meta_value=Spain’); ?>
ahead of the loop. But what I want to be able to do is to dynamically insert the name of the page into the part of the code where ‘Spain’ is.
I will have many countries and I don’t want to have to create an if/then statement for every country.
Is this possible?
- The topic ‘[Resolved] How to insert page title into query_posts with custom fields’ is closed to new replies.