Last active
April 19, 2016 14:15
-
-
Save pixelbart/466446848eb45c919c67417a106ba5db to your computer and use it in GitHub Desktop.
Custom WP-Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://codex.wordpress.org/Class_Reference/WP_Query | |
$args = array( | |
'category_name' => 'KATEGORIE1, KATEGORIE2', // Hier können einzelne Kategorie gewählt werden | |
'post_type' => 'post', // Hier wird angegeben, was angezeigt werden soll. (Post ist Standard; Geht auch Custom Post Type) | |
); | |
$the_query = new WP_Query( $args ); ?> | |
<?php if ( $the_query->have_posts() ) : ?> | |
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
<!-- AB HIER STARTET DER EINZELNE BEITRAG --> | |
<h2><?php the_title() ;?></h2> | |
<?php the_post_thumbnail(); ?> | |
<?php the_excerpt(); ?> | |
<!-- HIER ENDET DER EINZELNE BEITRAG --> | |
<?php endwhile; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php else : ?> | |
<!-- DAS WIRD AUSGEBEN, WENN KEINE BEITRÄGE VORHANDEN SIND --> | |
<p><?php _e( 'Keine Beiträge gefunden.', 'casacara' ); ?></p> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment