WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type (Post List Template) (5 posts)

  1. binarybit
    Member
    Posted 4 years ago #

    Hello Everyone... I have a question I have been trying to figure out over the past 4 hours which involves the use of custom post types.

    I currently have wordpress 3.0 setup with 5 custom post types one of which is for example "events".

    Now, I have everything working perfectly on the backend side of thing and I am able to get all the public event detail pages to show up (which follow the url string) http://www.domain.com/events/event-name-title

    I am using the single-post-type-name.php to style the individual event detail pages which works perfectly.

    The ONLY issue I have here is that I just can't seem to figure out a way to create a template page for the public event list page.

    In other words... I just want to have custom template assigned when a visitor goes to http://www.domain.com/events so I can list all the events associated with this custom post type.

    Can ANYONE please provide me with some quick guidance here??? I would greatly appreciate it.

  2. byronyasgur
    Member
    Posted 4 years ago #

    not sure - i am looking for something else myself but i came accross this and it might help you

    http://somadesign.ca/2010/smarter-custom-post-types-in-wordpress-3-0/

  3. MichaelH
    Member
    Posted 4 years ago #

    One solution is to create a page called "List of Events" and assign a page template to that page where the page template has something like:

    <?php
    $args=array(
      'post_type' => 'events',
      '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() ) {
      echo 'List of Events';
      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
      the_content();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  4. binarybit
    Member
    Posted 4 years ago #

    Is this really the only options... there is nothing which lets me create a type of list template for a post type??? I find this hard to believe that they did everything except for that for simple integration of these type of posts...

  5. MichaelH
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic