Post per page for Custom post types #wordpress
<?php /* Set posts per page for a custom post type in wordpress.php */ ?>
<?php
function set_posts_per_page_for_towns_cpt( $query ) {
  if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'towns' ) ) {
    $query->set( 'posts_per_page', '10' );
  }
}
add_action( 'pre_get_posts', 'set_posts_per_page_for_towns_cpt' );
?>
Show thumbnails in pagination #wordpress
<?php /* Show thumbnails in WordPress Posts Pagination */ ?>
<?php if( $prev_post = get_previous_post() ): ?>
    <div class="nav-box previous">
        <?php $prevthumbnail = get_the_post_thumbnail($prev_post->ID, 'thumbnail' );?>
        <?php previous_post_link('%link',"$prevthumbnail  <p>%title</p>", TRUE); ?>
    </div>
<?php endif; ?>
<?php if( $next_post = get_next_post() ): ?>
    <div class="nav-box next">
        <?php $nextthumbnail = get_the_post_thumbnail($next_post->ID, 'thumbnail' );  ?>
        <?php next_post_link('%link',"$nextthumbnail  <p>%title</p>", TRUE); ?>
    </div>
<?php endif; ?>
Better copyright #wordpress
<?php 
function synth_copyright() {
	global $wpdb;
	$copyright_dates = $wpdb->get_results("
		SELECT
		YEAR(min(post_date_gmt)) AS firstdate,
		YEAR(max(post_date_gmt)) AS lastdate
		FROM
		$wpdb->posts
		WHERE
		post_status = 'publish'
	");
	$output = '';
	if($copyright_dates) {
		$copyright = "&copy; " . $copyright_dates[0]->firstdate;
		if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
			$copyright .= '-' . $copyright_dates[0]->lastdate;
		}
		$output = $copyright.' - Site r&eacute;alis&eacute; par <a href="https://synth.agency" target="_blank">synth.agency</a>';
	}
	return $output;
} ?>
Show Future posts #wordpress
<?php // Loop
$recent = new WP_Query('post_type=event&post_status=future&order=ASC&orderby=date'); 
while($recent->;have_posts()) : $recent->the_post(); ?>
<div>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?> - <?php the_date('l, F j, Y');?></a>
</div>
<?php endwhile; ?>
<?php 
// Functions.php
add_filter('the_posts', 'show_future_posts');
function show_future_posts($posts){
    global $wp_query, $wpdb;
    if(is_single() && $wp_query->post_count ==0){
        $posts = $wpdb->get_results($wp_query->request);
    }
    return $posts;
}; ?>

No more items to load