I have a declared a custom post type in function.php like this :
register_post_type('movies', array(
'label' => __("Movies", TEMPLATENAME),
'singular_label' => __("Movie", TEMPLATENAME),
'public' => true,
'show_ui' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'post',
'hierarchical' => false,
'permalink_epmask' => EP_PERMALINK,
'rewrite' => array('slug' => 'cine', 'with_front'=> false),
'query_var' => 'movies',
'show_in_nav_menus' => true,
'menu_position' => 20,
'description' => __("These Movies will be automatically displayed on the « Movies » page.", TEMPLATENAME),
'labels' => array('add_new_item' => __( "Ajouter une movie", TEMPLATENAME), 'add_new' => __( "Ajouter une movie", TEMPLATENAME), 'edit_item' => __( "Modifier la movie", TEMPLATENAME), 'new_item' => __( "Nouvelle movie", TEMPLATENAME), 'view_item' => __( "Voir la movie", TEMPLATENAME), 'search_items' => __( "Chercher dans toutes les movies", TEMPLATENAME), 'not_found' => __( "Not Found", TEMPLATENAME), 'not_found_in_trash' => __( "No movie found in trash", TEMPLATENAME)),
'supports' => array('title', 'editor', 'thumbnail', 'excerpt','custom-fields')
//, 'register_meta_box_cb' => 'movies_box_fields'
));
Then I try to retrive them in a template file like this :
<?php query_posts(array ( 'post_type' => 'movies' )); ?>
It does not work, it retrieve the normal posts. If I use the post_type ‘event’ it works (it retrieve events from Event manager plugin).
What is wrong ?
Try:
<?php $loop = new WP_Query( array( 'post_type' => 'movies', 'posts_per_page' => 10 ) ); ?>
And also:
http://codex.wordpress.org/Function_Reference/flush_rewrite_rules
I finally manage to get the posts using get_posts()