• I have a custom post type called ‘products’.

    What URL do I need to type in to show ALL my posts belonging to that custom post type?

    I am using standard permalinks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Create a Page Template with the code below, then create a Page called products, and assign that Template to that Page.

    <?php
    /**
     * Template Name: Page of Products
     *
     * Selectable from a dropdown menu on the edit page screen.
     */
    ?>
    
    <?php get_header(); ?>
    
            <div id="container">
                <div id="content">
    
    <?php
    $type = 'products';
    $args=array(
      'post_type' => $type,
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
                </div><!-- #content -->
            </div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter betadog

    (@betadog)

    Thanks, MichaelH!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show all posts of a custom post type?’ is closed to new replies.