0% found this document useful (0 votes)
53 views1 page

Wordpress Custom Post Type

The document discusses displaying posts from a custom post type called 'book' on a page template. The template code shows how to query for published books and output them in the page's loop using custom post types and template tags.

Uploaded by

RK Das
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

Wordpress Custom Post Type

The document discusses displaying posts from a custom post type called 'book' on a page template. The template code shows how to query for published books and output them in the page's loop using custom post types and template tags.

Uploaded by

RK Das
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Using Custom Post Types A Page displaying the posts belonging to a custom post type.

In this case, the custom post type is book. The Template below is designed to work with the WordPress Twenty Eleven theme but is best used as a Twenty Ten Child Theme.
<?php /** * Template Name: Page of Books * * Selectable from a dropdown menu on the edit page screen. */ ?> <?php get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'book'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 2, 'ignore_sticky_posts'=> 1 ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); ?> <?php get_template_part( 'loop', 'index' );?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>

You might also like