Unable to display list of custom posts

I’m working on a project where I need to display a list of my custom post, just like with categories. I’ve made a custom post type (called “videoer”) in my functions.php:

function register_rc() { // A unique name for our function
$labels = array( // Used in the WordPress admin
    'name' => _x('Videoer', 'post type general name'),
    'singular_name' => _x('Video', 'post type singular name'),
    'add_new' => _x('Add New', 'Video'),
    'add_new_item' => __('Add New Video'),
    'edit_item' => __('Edit Video'),
    'new_item' => __('New Video'),
    'view_item' => __('View Video '),
    'search_items' => __('Search Videos'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash')
);
$args = array(
    'labels' => $labels, // Set above
    'public' => true, // Make it publicly accessible
    'hierarchical' => true, // No parents and children here
    'menu_position' => 5, // Appear right below "Posts"
    'has_archive' => 'resources', // Activate the archive
    'supports' => array('title','editor','comments','thumbnail','custom-fields'),
    'taxonomies' => array('category', 'post_type'),
    'public' => true,
    'show_ui' => true,
    'exclude_from_search' => true,
    'query_var' => true,
);

register_post_type( 'videoer', $args );

}

Read More

This works well in the wordpress admin area, and i can also display the posts correctly. I have given each post a category called videoer (the same name as the costum post type). Now if I want display all the post under the category videoer I get nothing.

I have tried this on my video-category.php:

    <?php $loop = new WP_Query( array( 'post_type' => 'videoer', 'posts_per_page' => 100   )  ); ?>
   <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
   <?php the_post_thumbnail(); ?>
   <h3><?php the_title() ?></h3>
   <a href="<?php the_permalink() ?>">Read More</a>

   <?php endwhile; ?>

Any advice is welcome!

Related posts

Leave a Reply

1 comment

    • Your videoer post type will have a post archive at example.com/videor that lists all videoer posts
    • You shouldn’t try to reinvent taxonomies using page templates. Instead use a custom taxonomy and call it something like videoer_category. Use the rewrite option on registration to change it to category and you’ll be able to have archives such as example.com/videor/category/<term name here>/
    • You can style your video category archives using the taxonomy-videoer_category.php template in your theme
    • You can then go on to style individual terms this way by going further down the template heirarchy. I recommend you look up the helpful chart on the codex
    • You can style your videoer posts using single-videoer.php
    • videoer is a fiddly name ( it isn’t a real english word ), perhaps you should rename it to video, or if you’re referring to the person who shoots the film, ‘Producer’
    • You use a lot of unnecessary PHP opening and closing tags. You don’t need to end a line with ?> and put <?php on the next line if there’s no HTML inbetween, it just makes it harder to read and easy to make silly mistakes