Hey guys hopefully someone out there can help me with this.
I have a bunch of pages that have custom fields within them. One of the custom fields I created is a checkbox named "featured". I’d like to grab the custom field values from all the pages that checked off the checkbox and feature them in the sidebar.
How do I write this if statement? You don’t! You don’t need an If statement here, you need to go back to your query_posts statement. Since you only want to select posts that have a certain custom field (or post meta in wordpress parlance) you will need add a couple of more parameters to this statement.
This will depend of course on what you called your custom fields and exactly what checking the box sets the field value to (since custom fields can only contain text – it might be set to ‘1’, ‘true’ or ‘TRUE’ depending on what you used to add the checkbox).