You can created a post template to display the CPT post details (i.e. videos/my-video) and you can create an archive template to display a list of posts (i.e. videos/).
To create a post template in a plugin, add the following to the plugin:
function include_templates( $template_path )
{
if ( get_post_type() == 'videos' )
{
if ( is_single() )
{
// checks if the file exists in the theme first,
// otherwise serve the file from the plugin
if ( $theme_file = locate_template( array( 'single-videos.php' ) ) )
{
$template_path = $theme_file;
}
else
{
$template_path = plugin_dir_path( __FILE__ ) . 'single-videos.php';
}
}
}
return $template_path;
}
add_filter( 'template_include', 'include_templates', 1 );
Then create a template called single-videos.php in the plugin folder:
<?php get_header(); ?>
<?php while(have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
To create a archive template in a plugin, add the following to the plugin:
function include_archive_template($archive_template)
{
global $post;
if ( is_post_type_archive ('videos') )
{
$archive_template = plugin_dir_path( __FILE__ ) . 'archive-videos.php';
}
return $archive_template;
}
add_filter( 'archive_template', 'include_archive_template' );
Then create the archive-video.php file on the plugin folder:
<?php get_header();
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$big = 999999999; // need an unlikely integer
// Get Video details
$args = array(
'post_type' => 'vdieos',
'order' => 'ASC',
'orderby' => 'title',
'posts_per_page' => 10,
'paged' => $paged
);
$wp_query = new WP_Query($args);
$page_args = array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'total' => $wp_query->max_num_pages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'list',
'add_args' => False,
'add_fragment' => ''
);
echo paginate_links( $page_args );
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="video_row clearfix">
<h3><a href="https://wordpress.stackexchange.com/questions/144437/<?php echo get_permalink( $post->ID ); ?>"><?php the_title() ?></a></h3>
<?php the_content(); ?>
<a href="https://wordpress.stackexchange.com/questions/144437/<?php echo get_permalink( $post->ID ); ?>">More Details</a>
</div>
<?php
endwhile;
echo paginate_links( $page_args );
wp_reset_postdata();
get_sidebar();
get_footer(); ?>