Über Web, Tech, Games, Art,
Code & Design

WordPress-Snippets

Datum deutsch

setlocale(LC_TIME, 'de_DE');
echo strftime("%a, %d. %B %Y", strtotime(CFS()->get('datum')));Code-Sprache: PHP (php)

WP_Query

<?php 
$args = array(
    'post_type' => 'post',
    'posts_per_page' => 3
);

$query = new WP_Query( $args );

if ( $query->have_posts() ) :  
    while ( $query->have_posts() ) : $query->the_post(); ?>  
    
        <div class="box">
            <h3><?php the_title(); ?></h3>
<a href="<?php echo get_permalink(); ?>" class="ghstbtn">zum Rückblick</a>
        </div>
        
    <?php endwhile; 
    wp_reset_postdata(); 
endif; ?>Code-Sprache: HTML, XML (xml)

Auszug

echo wp_trim_words( get_the_excerpt(), 35, '...' );Code-Sprache: PHP (php)

Pfad zum Theme

<?php echo get_template_directory_uri(); ?>Code-Sprache: HTML, XML (xml)

Thumbnail mit Timthumb

<img src="<?php echo get_template_directory_uri(); ?>/inc/timthumb.php?src=<?php echo get_the_post_thumbnail_url(); ?>&w=600">Code-Sprache: HTML, XML (xml)

Categoryname im Loop ausgeben

$cats = get_the_category();
$cat_name = $cats[0]->name;Code-Sprache: PHP (php)