Leave a Reply

2 comments

  1. With the help of @toscho pointing out get_post();, I was able to spit out a .csv with a blank template. At first, I had memory limit issues b/c of the amount of data, so I moved the site locally and was able to get everything I need with the get_post();

    This is the gist of it:

    <ol>
    <?php
    global $post;
    $args = array( 
        'numberposts' => -1,
        'orderby' => 'post_title',
        'order' => 'DESC',
        'post_type' => 'prospects',
        'post_status' => 'publish'
    );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post); ?>
        <li><?php echo $post->ID ?>, <?php the_title(); ?>, <?php echo get_field('prospect_profile_image'); ?>, <?php echo get_field('height'); ?>, <?php echo get_field('weight'); ?>, <?php echo get_field('born'); ?>, , <?php echo get_field('email'); ?>, <?php echo get_field('phone'); ?>, <?php echo get_field('street_address'); ?>, <?php echo get_field('city'); ?>, <?php echo get_field('state'); ?>, <?php echo get_field('zip_code'); ?>, <?php echo get_field('position_1'); ?>, <?php echo get_field('position_2'); ?>, <?php echo get_field('bats'); ?>, <?php echo get_field('throws'); ?>, <?php echo get_field('fathers_name'); ?>, <?php echo get_field('mothers_name'); ?></li>
    <?php endforeach; ?>
    </ol>
    

    I used an orderlist at first to make sure I was getting all the records.

  2. Use get_posts() and iterate over the result array. The argument 'numberposts' => -1 will produce a complete list of the posts.

    If you look at WP_Query::get_posts() in wp-includes/query.php you may get an idea how terrible complex such a query is (which is no excuse for the code style in this function …).

    And welcome to WordPress Stack Exchange!