Assigning a specific class per category and show its last post
-
Dear wordpress community,
I’m digging a bit through WordPress for few weeks now, trying to build my own theme. While trying to solve this issue, I bump on severals solution that might work, but I want to do it in the cleanest way possible.
Basically I modifying my index.php, and now it has 3 columns and right after it a 4 columns, what I try to achieve seems quite easy… But, how to assign each columns a specific category and displaying only 1 recent post?
<div class="my-first-column"> query_posts(array( 'posts_per_page' => 1, 'category' => 1)) // loop while(have_posts()) { the_post(); the_title(); // your custom-post-type post's title the_content(); // // your custom-post-type post's content } wp_reset_query() // reset the query </div> <div class="my-second-column"> query_posts(array( 'posts_per_page' => 1, 'category' => 2)) // loop while(have_posts()) { the_post(); the_title(); // your custom-post-type post's title the_content(); // // your custom-post-type post's content } wp_reset_query() // reset the query </div> <div class="my-third-column"> query_posts(array( 'posts_per_page' => 1, 'category' => 3)) // loop while(have_posts()) { the_post(); the_title(); // your custom-post-type post's title the_content(); // // your custom-post-type post's content } wp_reset_query() // reset the query </div>
and so on and so on. But then it seems a bit repetitive and maybe there would been a more reliable solution for that…
Thank you for your time.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Assigning a specific class per category and show its last post’ is closed to new replies.