wordpress - Prevent PHP variable from automatically displaying on the page -
i'm having strange occurrence haven't seen before. have created following variable:
$post_type = the_field('select_post_type');
so can use variable in other code (using wordpress advanced custom fields). however, @ point write line of code, outputs value onto page. query working correctly, reading variable otherwise. haven't seen variable before... ideas why or how can fix it?
here full code context:
<?php $post_type = the_field('select_post_type'); // variable outputting onto page right here $args = array( 'post_type' => $post_type, 'posts_per_page' => '-1', ); $query = new wp_query( $args ); ?>
i've used variables in wordpress queries before , haven't had happen, i'm not sure why happening?
the_field
automatically echo's use get_field
instead
Comments
Post a Comment