在Wordpress中使用强推荐的后置过滤器

时间:2018-09-19 08:02:50

标签: php wordpress filtering custom-post-type testimonials

大家好,我是这个迷人社区中的新手。那是我的问题。最近,我在WP中安装了插件Strong Testimonials。我有一个按类别的帖子搜索过滤器,该类别在其他自定义帖子部分称为校友中也起作用,但是现在我想使用“推荐书”的帖子按类别进行搜索过滤器,但它不起作用:(。我该怎么做数组显示按“证明插件”类别的过滤器?这是代码。谢谢!

-------------------------------------------------- - - - -码 - - - - - - - - - - - - -

    <div class="container">
        <?php
            $idObjPais = get_category_by_slug('pais'); // Obtener id de la categoria pais

            $subCategoriesPais = get_categories(array('child_of' => $idObjPais->term_id)); // Obtener las categorías hijas de la categoria pais

            $idObjPosgrado = get_category_by_slug('posgrado'); // Obtener id de la categoria pais

            $subCategoriesPosgrado = get_categories(array('child_of' => $idObjPosgrado->term_id)); // Obtener las categorías hijas de la categoria pais

            if(isset($_GET['pais']) && $_GET['pais']!='' && isset($_GET['posgrado']) && $_GET['posgrado']!=''){
                $filtro_cat[] = $_GET['pais'];
                $filtro_cat[] = $_GET['posgrado'];
                }
            else if(isset($_GET['pais']) && $_GET['pais']!=''){
                $filtro_cat[] = $_GET['pais'];
            }
            else if(isset($_GET['posgrado']) && $_GET['posgrado']!=''){
                $filtro_cat[] = $_GET['posgrado'];
            }
            ?>

        <div class="row mt-4">
            <?php while (have_posts()) { the_post(); ?>  
            <h1 class="col-12 top-title-alumnos"><?php the_title(); ?></h1>
            <?php } ?>
            <div class="col-12 top-text-alumnos">
                <?php the_content(); ?>
            </div>

            <div class="row wrapper m-4">
                <div class="col col-contador">
                  <i class="fa fa-users fa-3x-alumnos"></i>
                  <h2 class="timer count-title count-number" data-to="670" data-speed="2500"></h2>
                   <p class="count-text ">Alumnos ya <br> formados con EIP</p>
                </div>

                <div class="col col-contador">
                  <i class="fa fa-briefcase fa-3x-alumnos"></i>
                  <h2 class="timer count-title count-number" data-to="150" data-speed="2500"></h2>
                  <p class="count-text ">Empresas con convenio <br> de prácticas</p>
                </div>

                <div class="col col-contador">
                  <i class="fas fa-globe fa-3x-alumnos"></i>
                  <h2 class="timer count-title count-number" data-to="15" data-speed="1500"></h2>
                  <p class="count-text ">años formando <br>profesionales</p>
                </div>

            </div>

            <div class="col-12 the-filter">
                <form class="form-inline" action="<?php echo home_url('/nuestro-alumnado/');?>" method="get">
                    <div class="form-group col-md-4 col-12 input-drop btn-filtro">
                        <!-- <label class="mr-2" for="pais">País</label> -->
                        <select id="pais" name="pais" class="form-control">
                            <option value="" selected="selected">Todos los países</option>
                            <?php foreach ($subCategoriesPais as $pais) :
                                if($pais->term_id==$_GET['pais']){
                                    $selected = "selected";
                                }
                                else{
                                    $selected = "";
                                }
                                echo '<option value="'.$pais->term_id.'" '.$selected.'>'.$pais->name.'</option>';
                            endforeach;?>
                        </select>
                    </div> <!-- End drop Pais -->

                    <div class="form-group col-md-4 col-12 input-drop btn-filtro">
                        <!-- <label class="mr-2" for="pais">País</label> -->
                        <select id="posgrado" name="posgrado" class="form-control">
                            <option value="" selected="selected">Todos los posgrados</option>
                            <?php foreach ($subCategoriesPosgrado as $posgrado) :
                                if($posgrado->term_id==$_GET['posgrado']){
                                    $selected = "selected";
                                }
                                else{
                                    $selected = "";
                                }
                                echo '<option value="'.$posgrado->term_id.'" '.$selected.'>'.$posgrado->name.'</option>';
                            endforeach;?>
                        </select>
                    </div> <!-- End drop Pais -->

                    <div class="form-group col-md-4 col-12 btn-filtro">
                        <input type="submit" value="Buscar" class="btn btn-global" />
                    </div>
                </form>
            </div> <!-- Fin de buscador -->
        </div> <!-- Row end -->
    </div> <!-- End Container -->   

    <div class="container container-alumnos">
        <div class="row justify-content-center">

            <!-- Mostramos las entradas de alumnos -->


    <?php wp_reset_query();?>
    <?php query_posts(array(
    'post_type' => 'wpm-testimonial',
    'category_name' => 'wpm-testimonial-category', 
    'category__and' => $filtro_cat,
    'posts_per_page' => '-1',
    'order' => 'DESC', 
    'public' => true )); ?>



    <!-- Fin entradas alumnos -->

                <!-- empezamos el loop -->
                <?php while (have_posts()) { the_post(); ?>


            <div class="col-6 col-sm-5 col-md-3 col-lg-3 mr-2 mb-2 alumnos-item">
                <span class="bg-alumnos">
                    <span class="img-alumnos">
                                    <?php

                    if ( has_post_thumbnail() ) {
                        the_post_thumbnail();
                    }
                    else {
                        echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) 
                            . '/img/usuario.jpg" />';
                    }
                    ?>
                </span>

                        <h4 class="nombre-alumno">
                            <?php echo get_the_title(); ?>  

                        </h4><!--.nombre-docente + ld-->
                        <span class="pais-alumno">
                            <?php
                            $pais = get_post_meta(get_the_id(), 'pais', true);
                            if(!empty($pais)): ?>
                            <i class="fas fa-map-marker-alt" aria-hidden="true"></i> <?php echo $pais; ?>
                            <?php endif; ?>                     
                        </span>
                        <?php the_content(); ?> 

                                <!-- Redes del Alumno -->
                        <?php
                                $linkedin = get_post_meta(get_the_id(), 'contacto_linkedin', true);
                                if(!empty($linkedin)): ?>
                                     <a href="<?php echo $linkedin; ?>" target="_blank"> <!-- <span class="sr-only">Equipo docente - Formación y Empleo en Biomasa</span> --> <i class="fab fa-linkedin-in linkedin-card"></i></a>

                                <?php endif; ?>             
                </span><!--.bg-alumnos-->

            </div> <!--col-->

                <?php } ?> 


        </div><!--row-->


    </div> <!-- End Container -->   
</section><!--alumnos-->

0 个答案:

没有答案