making a function
-
This code works when I paste it into my template but I can’t work out how to convert it into a function everytime I do it messes up the rest of my template!
I’m also pretty sure there’s a cleaner way to do this and suggestions are welcome. Basically I want to display 6 pages with the custom field project_active = yes.
<?php $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'project_active' AND wposts.post_type = 'page' ORDER BY wpostmeta.meta_value DESC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <ul> <?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <li><a href="the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> <?php endif; ?> </ul>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘making a function’ is closed to new replies.