0

I'm using Wordpress as more CMS than blog, and I want to create a theme that uses 9 specific posts on the home page.

I don't want those posts to show up in other lists. I don't want other posts to accidentally override these posts. My rough sense is that I'd put the 9 posts in a single category (front) and then give each one a placement tag (top center / middle left / etc) and build a static front page around that.

Am I on the right track here?

0

The easiest way to achieve this would be to use a custom post type. This way, these posts won't show up as custom post types by default are excluded from the main query.

You can just then create your page and create a custom query with WP_Query to pull in this 9 posts

1. CREATE CUSTOM POST TYPE

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'acme_product',
        array(
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
        'public' => true,
        'has_archive' => true,
        )
    );
} 

2. CREATE YOUR CUSTOM QUERY

<?php

// The Query
$args = array(
  'post_type' => 'acme_product',
  'posts_per_page' => 9
);
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
    echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
    echo '</ul>';
} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

All you have to do know is setup your page template, set it as front page and add your 9 posts

I hope this helps

  • Did my answer solved your problem. If yes, please consider accepting my answer by clicking on the check mark on the left of my answer below the up/down arrow. If not, what problem do you still have? – Pieter Goosen Jul 6 '14 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.