So I have a dropdown menu that has a list of all pages using a certain template, when the user selects a dropdown item id like them to be re-directed to that page.
Here is what I have so far...
<div class="col-md-6 col-md-offset-3">
<?php
//create a var using get_pages create an array and get all page names
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'template-services.php'
));
?>
<p>Looking for something else?</p>
<select id="cat" class="form-control">
<?php
// for each item in pages array assign to the new var page
foreach( $pages as $page ) {
//echo out var page for each item in the array
echo '<option>' . $page->post_title . '</option>';
}?>
</select>
</div>
Could someone show me how I can achieve this? I know there is a script on the Wordpress codex that allows you to do this for categories but I have no idea how to modify it to work for my needs