views:

47

answers:

1

I am using WordPress 3 and I created a custom post type called article, which gives me the url format of mywebsite/articles/article-title. How do I see all the article entries in the url mywebsite/articles?

+2  A: 

Assuming you set up everything correctly and you want to see the post type on a public template page try this code into mycustomtemplate.php or eqivilate.

    <?php $loop = new WP_Query( array( 'post_type' => 'article', 'posts_per_page' => 10 ) ); ?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>

    <div class="entry-content">
        <?php the_content(); ?>
    </div>
<?php endwhile; ?>

You can customize the loop just like you would blog post and pages. If you want to get ALL on one page you'll want to remove the limit of 10 on post_per_page I wouldn't suggest it though. I would say set it to 50 or 100 and still use pages.

Source: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress

BandonRandon
How do i make mywebsite/articles use the template mycustomtemplate.php?
Giljed Jowes
You should be able to add `'rewrite' => array( 'slug' => 'articles', 'with_front' => false ),` to your array when you set up the `register_post_type` variable. See the link I posted as the source above.
BandonRandon
You should also be able to add something like single-mycustomtemplate.php
BandonRandon