Adding a Permalink in a foreach loop
-
I’m trying to output a list of pages that use a particular page template, with their title as a link.
This is my code so far:
<?php $studentpages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'students.php' )); foreach($studentpages as $studentpage){ $students = $studentpage->post_title; echo '(<a href="'get_permalink();'">'$students'</a>)'.'<br />'; } ?>
If I just echo $students I get my list but I would like them to be links. This is being used on a sitemap and the code is outside of the loop.
Can anyone please help?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Adding a Permalink in a foreach loop’ is closed to new replies.