Title: Query Custom Type posts
Last modified: August 20, 2016

---

# Query Custom Type posts

 *  [Godaisies](https://wordpress.org/support/users/godaisies/)
 * (@godaisies)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-custom-type-posts/)
 * I am trying to display custom post types on the front of my website (which will
   be a YouTube video).
 * My website is [here](http://s248198300.onlinehome.us/dlc/) and the video will
   show up in that light blue box on the right side of the site. However, I can 
   get nothing to show up!
 * I have tried using this code:
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   
       					<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>>
   
       <?php
       $args = array('post_type' => '<custom_type>',
                     'posts_per_page' => 1,
                )
       ?>
       ?>
       ```
   
 * My custom post type looks like this:
 *     ```
       // let's create the function for the custom type
       function custom_post_example() {
       	// creating (registering) the custom type
       	register_post_type( 'custom_type', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */
       	 	// let's now add all the options for this post type
       		array('labels' => array(
       			'name' => __('Video Posts', 'post type general name'), /* This is the Title of the Group */
       			'singular_name' => __('Video Post', 'post type singular name'), /* This is the individual type */
       			'add_new' => __('Add New', 'custom post type item'), /* The add new menu item */
       			'add_new_item' => __('Add New Video Post'), /* Add New Display Title */
       			'edit' => __( 'Edit' ), /* Edit Dialog */
       			'edit_item' => __('Edit Post Types'), /* Edit Display Title */
       			'new_item' => __('New Post Type'), /* New Display Title */
       			'view_item' => __('View Post Type'), /* View Display Title */
       			'search_items' => __('Search Post Type'), /* Search Custom Type Title */
       			'not_found' =>  __('Nothing found in the Database.'), /* This displays if there are no entries yet */
       			'not_found_in_trash' => __('Nothing found in Trash'), /* This displays if there is nothing in the trash */
       			'parent_item_colon' => ''
       			), /* end of arrays */
       			'description' => __( 'This is the example custom post type' ), /* Custom Type Description */
       			'public' => true,
       			'publicly_queryable' => true,
       			'exclude_from_search' => false,
       			'show_ui' => true,
       			'query_var' => true,
       			'menu_position' => 8, /* this is what order you want it to appear in on the left hand side menu */
       			'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png', /* the icon for the custom post type menu */
       			'rewrite' => true,
       			'capability_type' => 'post',
       			'hierarchical' => false,
       			/* the next one is important, it tells what's enabled in the post editor */
       			'supports' => array( 'title', 'editor', 'comments', 'revisions', 'sticky')
       	 	) /* end of options */
       	); /* end of register post type */
   
       	/* this ads regular categories to your custom post type */
       	register_taxonomy_for_object_type('category', 'custom_type');
       	/* this ads regular tags to your custom post type */
       	register_taxonomy_for_object_type('post_tag', 'custom_type');
   
       } 
   
       	// adding the function to the WordPress init
       	add_action( 'init', 'custom_post_example');
   
       ?>
       ```
   

The topic ‘Query Custom Type posts’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [post query](https://wordpress.org/support/topic-tag/post-query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Godaisies](https://wordpress.org/support/users/godaisies/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/query-custom-type-posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
