Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $args = array(
- 'post_type' => array('post'),
- 'order' => 'DESC',
- 'category_name' => 'test',
- );
- // The Query
- $query = new WP_Query( $args );
- // The Loop
- if ( $query->have_posts() ) {
- while ( $query->have_posts() ) {
- $query->the_post();
- // Your custom code
- }
- } else {
- // no posts found
- }
- /* Restore original Post Data */
- wp_reset_postdata();
- <?php
- global $post;
- $args = array( 'numberposts' => 10, 'category_name' => 'cat-slug' );
- $posts = get_posts( $args );
- foreach( $posts as $post ){
- setup_postdata($post);
- get_the_title();
- get_the_excerpt();
- get_the_content();
- }
- ?>
- $wp_argu = array(
- 'post_type' => 'prayer',
- 'posts_per_page' => '-1',
- 'suppress_filters' => false,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'category',
- 'field' => 'slug', // id, name
- 'terms' => 'bob',
- ),
- ),
- );
- $query = new WP_Query( $wp_argu );
Add Comment
Please, Sign In to add comment