Need to pull custom post type's titles and id's inside functions.php Following code is working fine if used in page template. But doesn't return anything inside a functions.php
<select name="feat_pop" value="<?php echo $feat_pop; ?>">
    <option value="none">None</option>
    <?php
        global $post;
        $popargs = array(                        
                            'posts_per_page' => -1, 
            'post_type' => 'popups'
        );
            $newpop = new WP_Query( $popargs );
        if ( have_posts() ) while ($newpop->have_posts()) : $newpop->the_post();
    ?>
            <option value=""><?php the_title();?></option>
    <?php
        endwhile; 
        wp_reset_postdata();
    ?>
</select>
The only error in error logs- "Got error 'PHP message: PHP Parse error: syntax error, unexpected end of file" But there is nothing at specified line.
 
    