Getting Custom Post Types on Your WordPress Front Page

 

Hi guys and gals, my name is Theokie and recently I needed to have my WordPress Home Page display a custom post type. Firstly go to your theme’s index.php file and open it. Look for where The Loop starts, usually

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

now place this just before The Loop

<?php
$args = array( 'post_type'=> 'product' );
query_posts( $args );
?>

You could add more post types to the query by replacing the above with

$args = array ( 'post_type' => array('product' , 'post' ));
query_posts( $args );

Remember to reset the Query just after The Loop by adding this

<?php wp_reset_query(); ?>

Now you should see your custom posts on the FrontPage :) WordPress Rocks!!

 

No comments yet.

Leave a Reply