Problem displaying specific pages/posts
-
I’m trying to mod the visionary theme in wordpress so that the homepage displays 7 specific posts/pages on the front page. these pages would be static and not change. The idea is they’d take the place of the latest news spots.
My question is, can I use an array to call out specific post IDs all at once (in a loop)? If so, how would I go about doing this?
I’ve read the get_post function/reference on the codex but I’m still none the wiser.I’ve been given this solution, but I’m wondering if there is a quicker/neater way of achieving the same thing?
<?php $i = 1; while($i <= 7) { switch($i) { case 1: $my_id = 351; break; case 2: $my_id = 351; break; case 3: $my_id = 351; break; case 4: $my_id = 351; break; case 5: $my_id = 351; break; case 6: $my_id = 351; break; case 7: $my_id = 351; break; default: echo "No Posts!"; break; } $post_id = get_post($my_id); $title = $post_id->post_title; $content = $post_id->post_content; echo '<div class="post">'; echo '<h2 class="post-title">'; echo '<a href="' . get_permalink(351) . ' " title="' . $title . ' ">' . $title . '</a>'; echo '</h2>'; echo '<div class="entry">' . $content . '</div>'; echo '</div>'; $i++; } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problem displaying specific pages/posts’ is closed to new replies.