Bring Post with query wordpress

0

I'm having a problem with this website on ALL's side COURSES. I am wanting to bring in the list all the courses that I am uploading in a Post Type called course, for that I assigned some taxonomies (Edgecam, Radan, Apahacam) where I tell which brand that course belongs to. For example, the URL that attached Edgecam Standard Milling that is a course belongs to the Edgecam taxonomy. Although the titles of the drop-down are well placed, I do not know how to bring the P

Una solución podría ser que por cada término cuyo valor va tomando la variable $termino busques sus posts relacionados con la función get_posts().

Te dejo un ejemplo de como podría ser esta consulta, faltaría que iteraras sobre el array de resultados de la consulta de posts para listarlos de la forma que te convenga.

<?php

$terms = get_terms( array(
        'taxonomy'   => 'categoria-cursos',
        'parent'     => get_queried_object()->term_id,
        'hide_empty' => false,
    )
);



foreach ($terms as $termino) {

    $posts_array = get_posts(
        array( 'showposts' => -1,
               'post_type' => 'curso',
               'tax_query' => array(
                   array(
                       'taxonomy' => 'categoria-cursos',
                       'field' => 'name',
                       'terms' => $termino->name,
                   )
               )
        )
    );?>

    <div id="accordion-container">
        <h2 class="accordion-header ">
            <?php echo $termino->name; ?>
        </h2>
        <div class="accordion-content" >
            <ul class="icons longarrowlist">
                <li>
                    <a href="<?php echo get_term_link($termino); ?>">
                        <b class="colortext">
                            <?php the_sub_field('texto'); ?> // este acf no iria tendria que traer el post del curso.
                        </b>
                    </a>
                </li>
            </ul>
        </div>
    </div>
<?php } ?>

ost (in this case they would be the titles) with its said link.

    
asked by MarianoF 25.04.2018 в 20:50
source

0 answers