News Update :
Home » » Query WordPress post - Request to database

Query WordPress post - Request to database

By: Unknown on Wednesday 18 February 2015 | 10:52

A database is convenient, even if one is able to evade the desired information. The following example can be applied to one article or Post Type personalize.

The first step is to assign the arguments, in other words; whom, in what category, how .$ Arg = ... ..

 




Creating the Loop

Close the loop

Reinstall the loop

post_type: Your guy, if you want to delete items by default.


<?php
// The Query

 $args = array(

'post_type' => 'votre_post_type',
 'posts_per_page'=> '1'
 );
 $query = new WP_Query( $args );

 // The Loop
 if ( $query->have_posts() ) {
 while ( $query->have_posts() ) {
 $query->the_post();?>

 <ul class="row">

 <?php the_title(); ?>

 <?php
 }
 } ?>

<?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