WP List all Custom Posts

Discussion in 'PHP' started by Spilgrim, Aug 5, 2014.

  1. #1
    I built a separate page template and I keep getting: "Parse error: syntax error, unexpected '$my_query' (T_VARIABLE), expecting ')' in /.../.../public_html/wp-content/themes/OpenDoor1.4/pagetemplate-vehicleinv.php on line 22"

    Line 22 is:
    $my_query = null;
    Code (markup):
    The entire section is:
    
    <?php
    $type = 'listing';
    $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().
    ?>
    
    Code (markup):
    I just have no idea why it won't populate the custom post type "listing'
     
    Spilgrim, Aug 5, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You're missing the ending ) after the array...
     
    PoPSiCLe, Aug 6, 2014 IP