Hello, I am doing this web page where I have some courses that I upload directly in Post type courses but I have to filter them in this page that I attached above. The site is made for two countries Mexico and Argentina and I need the people of Mexico to see exclusively the courses of their country? For that use a plugin called GeoIP Detection to get the ID in this case from Mexico and a function that is this that I highlight
function estoy_en_mexico(){
$ipinfo = geoip_detect2_get_info_from_current_ip();
if ($ipinfo) {
return $ipinfo->country->isoCode === 'MX'; // en realidad deberia ir MX y no AR
}
return false;
}
Well, what I need now is to generate a function on the page that I attached that is the one that filters the courses and takes so much important image title and content, so that when a person navigates in that country he can see the courses that he they correspond to that country. I to the post type course generate a check to tell you this course belongs to mexico eg. What I'm missing is to filter the courses by country because in the section that you attach above you can see all of them.
The code for the course filtering is as follows
<div class="col-md-8 animated fadeInLeft notransition">
<h2 class="smalltitle">
<span>Nuestros Cursos</span>
</h2>
<div class="row">
<div class="col-md-12 text-center">
<div id="filter" class="animated fadeInDown bottomspace10">
<ul>
<li><a href="#" data-filter="*" class="selected"><i class="icon icon-reorder"></i> Ver Todos</a></li>
<li><a href="#" data-filter=".activo" title="¡Fechas Definidas!"><i class="icon icon-th"></i> Cursos Activos</a></li>
<li>Líneas:</li>
<?php
$terms = get_terms('categoria-cursos', get_queried_object());
if($terms){
foreach ($terms as $termino){ ?>
<li>
<a href="#" data-filter=".id<?php echo $termino->term_id;?>"><i class="icon icon-th"></i>
<?php echo $termino->name; ?>
</a>
</li>
<?php } }?>
</ul>
</div>
</div>
</div>
<!-- END filtering menu -->
<div id="content">
<?php if($terms){ //si existe contenido
foreach($terms as $termino){
$args = array(
'post_type' => 'curso',
'showposts'=> -1,
'tax_query' => array(
array(
'taxonomy' => 'categoria-cursos',
'field' => 'id',
'terms' => $termino->term_id
)
)
);
$posts = new WP_Query( $args );
if($post){
while($posts->have_posts()):
$posts->the_post();
$cur = $post;
?>
<div class="boxportfolio1 bp-height item id<?php echo $termino->term_id;?> <?php if (get_field('curso_activo', $cur->ID,true) == 'habilitado') { echo 'activo'; }?>">
<!-- desde acá parte un bloque -->
<div class="boxcontainer">
<div class="prod-imagecontainer">
<img src="<?php echo get_the_post_thumbnail_url($cur->ID,'thumbnail'); ?>" alt="<?php echo $cur->post_title; ?>">
</div>
<div class="roll">
<div class="wrapcaption">
<a href="<?php echo get_the_permalink($cur->ID); ?>"><i class="icon-arrow-right captionicons"></i></a>
</div>
</div>
<div class="prod-infocontainer">
<h1>
<a href="vero-alphacam-router.html">
<?php echo $cur->post_title; //este es tl titulo?>
</a>
</h1>
<p>
<?php echo get_the_content($cur->ID);?>
</p>
</div>
</div>
</div>
<?php endwhile;
}
?>
<?php } } ?>
</div>
</div>
<?php if(estoy_en_mexico() && !get_field('cursos_mexico')){
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 ); exit();
} ?>