Namecheap.com - Cheap domain name registration, renewal and transfers - Free SSL Certificates - Web Hosting

Display all Post types and Custom Post types in Home Page



Creation of multiple post types can't  be displayed all in your themes home page. All you have to do is to add the following code into your theme "functions.php" file or main plugin file to view it on your home page

<?php 
add_filter( 'pre_get_posts', 'kv_wp_get_posts' );
function kv_wp_get_posts( $query ) {
if ( is_home() )
$query->set( 'post_type', array( 'post', 'page', 'custom post types', 'attachment' ) );
else if(is_front_page())
$query->set( 'post_type', array( 'post', 'page', 'custom post types', 'attachment' ) );
return $query;
}

?>

Here post, pages, custom_post types and attachments are athe post types, you can add your own custom post types which you registered already,

1 Responses to “Display all Post types and Custom Post types in Home Page”

Anonymous said...
14 June 2013 at 20:25

Everу weekend i usеd to pay a quіck viѕit this wеbsite, for the reason
that i want enjoyment, since thiѕ this web ѕіte conationѕ actually
good funny infoгmation toο.

Look іntο my wеb sitе; herbal incense kentucky


Post a Comment

Namecheap.com - Cheap domain name registration, renewal and transfers - Free SSL Certificates - Web Hosting