News Update :
Home » » Query Post - Post types - Taxonomy

Query Post - Post types - Taxonomy

By: Unknown on Friday 20 February 2015 | 11:28

If you created a post guy, you probably also created one or more taxonomy.

Class or taxonomy?

In fact when we created a taxonomy or low call category :)

 





In our case:

I created a post type called System and added a taxonomy system called Category:

query-post-taxonomy


On this page you can see at:

/wp-admin/edit-tags.php?taxonomy= our products & post_type = system



In the address that give us two important information to build our request.

taxonomy = our-products
post_type = system

Then if you want to call air conditioners must rely on the identifier.

air conditioners

So the query will be, to call all the air conditioner:



<?php
// La requête au serveur
    $args = array( 
        'post_type' => 'systeme',
        'nos-produits' => 'climatiseurs', 
        'posts_per_page' => -1 
    );

    // Le résultat
    $the_query = new WP_Query( $args );

    // La boucle
    ?>
    <?php if( $the_query->have_posts() ): ?>
        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
               
                <div class="img-vedette">
                    Votre HTML
                </div>
               
           
        <?php endwhile; ?>

    <?php endif; ?>

<?php wp_reset_query();  // Réinitialiser la requête ?>
 
Contact Us | Privacy policy | Term of use | Advertise with Us | Site map
Copyright © 2011. Blogging Brain . All Rights Reserved.
Design Template by Blogging Brain | | Powered by Blogger