I have a custom post type, and its not showing the content with in my archive page(Videos), What am i doing wrong. here is the code. I appreciate the help guys.
THE VIDEOS POST TYPE
<?php
/**
* CUSTOM POST TYPES
*/
add_action('init','videos_post_type');
function videos_post_type(){
$labels = array(
'name' => __( 'Videos', 'text-domain' ),
'singular_name' => __( 'Video', 'text-domain' ),
'add_new' => _x( 'Add New Video', 'text-domain', 'text-domain' ),
'add_new_item' => __( 'Add New Video', 'text-domain' ),
'edit_item' => __( 'Edit Video', 'text-domain' ),
'new_item' => __( 'New Singular Name', 'text-domain' ),
'view_item' => __( 'View Videos', 'text-domain' ),
'search_items' => __( 'Search Videos', 'text-domain' ),
'not_found' => __( 'No Plural Name found', 'text-domain' ),
'not_found_in_trash' => __( 'No Plural Name found in Trash', 'text-domain' ),
'parent_item_colon' => __( 'Parent Singular Name:', 'text-domain' ),
'menu_name' => __( 'Videos', 'text-domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'description',
'taxonomies' => array(),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => null,
'menu_icon' => null,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug'=>'videos'),
'capability_type' => 'post',
'supports' => array('title', 'thumbnail','page-attributes','editor')
);
register_post_type('Videos', $args);
}
THE archive-videos template
<?php get_header();?>
<section class="videos">
<div class="video_banner">
<img src="<?php echo get_template_directory_uri().'/images/image 2.jpg';?>" alt="">
<h3 class="videos_title"><?php wp_title('');?> </h3>
<?php
$args = array(
'post_type'=> 'videos',
'orderby'=> 'menu_order',
'post_per_page'=> 4
);
$videos = new WP_QUERY($args);
?>
<?php if ( $videos->have_posts() ) :?>
<?php while ( $videos->have_posts() ) : $videos-> the_post(); ?>
<?php get_template_part('loop', 'videos' );?>
<!-- post -->
<?php endwhile; ?>
<!-- post navigation -->
<?php else: ?>
<?php endif; ?>
</div><!-- END CONTAINER-->
</div>
</section>
Rename your post type to
videos
. This should solve your problem.Here is a few golden rules for naming conventions when creating custom post types and custom taxonomies
never use camelcase, all characters should be lowercase
never use special characters, except underscores
stay clear of reserved names
Also, drop your custom query and just use the default loop. If you need to change anything in the main query, rather use
pre_get_posts