I'm running a simple query that displays some posts within a custom post type.
Via each post within that post type, I've added an ACF True / False checkbox. If the checkbox is ticked, I'd like that post to only appear if you're within the USA.
Here's what I have so far:
<?php // Begin loop
while ( have_posts() ) : the_post(); ?>
<article>
<?php // If within the USA
if(get_field('usa')) {
?>
<?php // Query post
$args = array(
'post_type' => 'projects',
'posts_per_page' => 12
);
$get_projects = new WP_Query( $args );
while ( $get_projects->have_posts() ) :
$get_projects->the_post();
?>
<section>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<?php the_content(); ?>
</section>
<?php // End query post type
endwhile;
wp_reset_postdata();
?>
<?php } // end if
else { // The rest of the world ?>
<?php // Query post
$args = array(
'post_type' => 'projects',
'posts_per_page' => 12
);
$get_projects = new WP_Query( $args );
while ( $get_projects->have_posts() ) :
$get_projects->the_post();
?>
<section>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<?php the_content(); ?>
</section>
<?php // End query post type
endwhile;
wp_reset_postdata();
?>
<?php } // end else ?>
</article>
<?php endwhile; // End loop ?>
Am I correct in thinking that I'll need to add to the USA query by specifying a specific IP range? I couldn't find anything via conditional tags on the codex.