Output custom user roles and users wordpress frontend

<?php 
// Functions.php
// Return editable roles
function get_editable_roles() {
    global $wp_roles;
    $all_roles = $wp_roles->roles;
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}
// Custom Role with no capabilities (subscriber like)
add_role('custom-role', __('Custom Role'), array('read' => true));
// Remove a role
// remove_role( 'subscriber' );
// add custom field to user profile
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="poste">Poste</label></th>
<td>
<input type="text" name="poste" id="poste" value="<?php echo esc_attr( get_the_author_meta( 'poste', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
    return false;
	update_usermeta( $user_id, 'poste', $_POST['poste'] );
}
?>

<?php 
// custom-template.php
?>     
<dl>
<?php foreach (get_editable_roles() as $role_name => $role_info): ?>
  <?php if ($role_name != 'administrator') { /* Hide admin */  ?>
  	<dt><?php echo translate_user_role( $role_info['name'] ); ?></dt>
  		<?php $args = array('role' => $role_name,'meta_key' => 'last_name','orderby'  => 'meta_value','order' => 'ASC'); $users = get_users($args); ?>
		<?php foreach ($users as $user) { ?>
		<dd>
			<h3><?php echo $user->last_name; ?> <?php echo $user->first_name;?></h3>
			<span class="usr-statut"><?php /* Echo custom field */ $poste = get_user_meta($user->ID,'poste',true); echo $poste;?></span>
			<span class="usr-contacts"><a href="mailto:<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></span>
		</dd>
		 <?php } wp_reset_query(); ?>
  <?php }  ?>
<?php endforeach; ?>
</dl>

<?php 
// Plugin for reordering alphabetically Roles
// plugins / t5-sort-editable-roles.php
?>
<?php
/**
 * Plugin Name: T5 Sort Editable Roles
 * Description: Sort roles by their display name.
 * Plugin URI:  http://wordpress.stackexchange.com/questions/74785/alphabetically-order-role-drop-down-selection-in-dashboard
 * Version:     2012.12.03
 * Author:      Thomas Scholz
 * Author URI:  http://toscho.de
 * Licence:     MIT
 * License URI: http://opensource.org/licenses/MIT
 */

add_filter( 'editable_roles', 't5_sort_editable_roles' );

/**
 * Array of roles.
 *
 * @wp-hook editable_roles
 * @param   array $roles
 * @return  array
 */
function t5_sort_editable_roles( $roles )
{
	uasort( $roles, 't5_uasort_editable_roles' );
	return $roles;
}
/**
 * Compare translated role names.
 *
 * @param  array $a First role
 * @param  array $b Second role
 * @return number
 */
function t5_uasort_editable_roles( $a, $b )
{
	return strcasecmp(
		translate_user_role( $a['name'] ),
		translate_user_role( $b['name'] )
	);
}

Better copyright

 // http://www.wpbeginner.com/wp-tutorials/how-to-add-a-dynamic-copyright-date-in-wordpress-footer/
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;
}

Post per page CPT

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' );

Add plus-minus quantity increment in WooCommerce

/* http://wcodex.co.in/add-plus-minus-quantity-increment-woocommerce-store/
woocommerce/global/quantity-input.php */
<div class="quantity">
  <input class="minus" type="button" value="-">
  <input type="number" ... size="4" />
  <input class="plus" type="button" value="+">
</div>
/* CSS */
input[type="number"] {
    -moz-appearance: textfield;
}
.minus {
    border:none;
    color:#fff;
    background-color:purple;
    height:30px;
    width:30px;
}
.plus {
    border:none;
    color:#fff;
    background-color:purple;
    height:30px;
    width:30px;
}
.qty {
    border:1px solid purple;
    color:purple;
    height:30px;
     
}
/* JS */
jQuery(document).ready(function($){
        $('.quantity').on('click', '.plus', function(e) {
            $input = $(this).prev('input.qty');
            var val = parseInt($input.val());
            $input.val( val+1 ).change();
        });
 
        $('.quantity').on('click', '.minus', 
            function(e) {
            $input = $(this).next('input.qty');
            var val = parseInt($input.val());
            if (val > 0) {
                $input.val( val-1 ).change();
            } 
        });
    });

Show Future posts

<?php $recent = new WP_Query('post_type=event&post_status=future&order=ASC&orderby=date'); while($recent->;have_posts()) : $recent->the_post(); ?>
    <div>
        <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
        <span><?php the_date('l, F j, Y');?></span>
    </div>
<?php endwhile; ?>

// Functions.php
add_filter('the_posts', 'show_future_posts');
function show_future_posts($posts){
global $wp_query, $wpdb;
if(is_single() &amp;&amp; $wp_query-&gt;post_count ==0){
$posts = $wpdb-&gt;get_results($wp_query-&gt;request);
}
return $posts;
};

Show thumbnails in pagination

<?php if( $prev_post = get_previous_post() ): ?>
    <div class="nav-box previous">
        <?php $prevthumbnail = get_the_post_thumbnail($prev_post->ID, '500x500' );?>
        <?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, '500x500' );  ?>
        <?php next_post_link('%link',"$nextthumbnail  <p>%title</p>", TRUE); ?>
    </div>
<?php endif; ?>

Enable Ftp wp upload

define('FS_METHOD','direct'); // add this to wp-config.php

Load post content via Ajax & Jquery

<?php 
// https://stanhub.com/load-wordpress-post-content-with-ajax-and-jquery/
if (have_posts()) : while (have_posts()) : the_post(); ?>
<a class="post-link" rel="<?php the_ID(); ?>" href="<?php the_permalink(); ?>">
 <div id="<?php $category = get_the_category(); echo $category[0]->cat_name; ?>"> 
   <?php the_post_thumbnail(); ?>
   <span class="title"><?php the_title(); ?></span>    
   <span class="excerpt"><?php the_excerpt(); ?></span>
</div>
</a>
<?php endwhile; endif; ?>
<div id="single-post-container"></div></code>
<?php
 // single.php
    $post = get_post($_POST['id']);
?>
    <div id="single-post post-<?php the_ID(); ?>">
    <?php while (have_posts()) : the_post(); ?>
                <?php the_title();?>
                <?php the_content();?>
    <?php endwhile;?> 
</div>
<script>
   $(document).ready(function(){
 
        $.ajaxSetup({cache:false});
        $(".post-link").click(function(){
            var post_link = $(this).attr("href");
 
            $("#single-post-container").html("content loading");
            $("#single-post-container").load(post_link);
        return false;
        });
 
    });
</script>

Single custom post type pagination same custom taxonomy

<?php $prev_post = get_adjacent_post( true, '', true, 'taxonomy_slug' ); ?>
 <?php if ( is_a( $prev_post, 'WP_Post' ) ) { ?>
 	<a href="<?php echo get_permalink( $prev_post->ID ); ?>"><?php echo get_the_title( $prev_post->ID ); ?></a>
 <?php } ?>

<?php $next_post = get_adjacent_post( true, '', false, 'taxonomy_slug' ); ?>
 <?php if ( is_a( $next_post, 'WP_Post' ) ) {  ?>
 	<a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo get_the_title( $next_post->ID ); ?></a>
 <?php } ?>

Loop with custom Post type & custom taxonomy term

<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => 'YourPostType', 'YourTax' => 'YourTaxTerm', 'showposts' => 8, 'orderby' => 'date', 'order' => 'DESC', 'post_status'=> 'publish', 'ignore_sticky_posts' => 1, 'paged' => $paged ) ); ?>
<?php if (have_posts()) : ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li class="grid-item" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); ?>

Photo gallerie products

<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
global $post, $product, $woocommerce;
?>
<div class="images">
	<ul>
		<li>
	<?php
		if ( has_post_thumbnail() ) {
			$attachment_count = count( $product->get_gallery_attachment_ids() );
			$gallery          = $attachment_count > 0 ? '[product-gallery]' : '';
			$props            = wc_get_product_attachment_props( get_post_thumbnail_id(), $post );
			$image            = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
				'title'	 => $props['title'],
				'alt'    => $props['alt'],
			) );
			echo apply_filters(
				'woocommerce_single_product_image_html',
				sprintf(
					'<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto%s">%s</a>',
					esc_url( $props['url'] ),
					esc_attr( $props['caption'] ),
					$gallery,
					$image
				),
				$post->ID
			);
		} else {
			echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="%s" />', wc_placeholder_img_src(), __( 'Placeholder', 'woocommerce' ) ), $post->ID );
		}
	?>
		</li>
	
	
	
<?php 
		//global $post, $product, $woocommerce;

$attachment_ids = $product->get_gallery_attachment_ids();

if ( $attachment_ids ) {
	$loop 		= 0;
	$columns 	= apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
	?>
	<li><?php

		foreach ( $attachment_ids as $attachment_id ) {

			$classes = array( 'zoom' );

			if ( $loop === 0 || $loop % $columns === 0 ) {
				$classes[] = 'first';
			}

			if ( ( $loop + 1 ) % $columns === 0 ) {
				$classes[] = 'last';
			}

			$image_class = implode( ' ', $classes );
			$props       = wc_get_product_attachment_props( $attachment_id, $post );

			if ( ! $props['url'] ) {
				continue;
			}

			echo apply_filters(
				'woocommerce_single_product_image_thumbnail_html',
				sprintf(
					'<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a></li>',
					esc_url( $props['url'] ),
					esc_attr( $image_class ),
					esc_attr( $props['caption'] ),
					wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), 0, $props )
				),
				$attachment_id,
				$post->ID,
				esc_attr( $image_class )
			);

			$loop++;
		}

	?>
	
	</li>
	<?php
}

	?>
	</ul>
	<div class="clear"></div>
</div>
<?php 

echo taxonomy term & url in single template

<?php $terms = get_the_terms( $post->ID , 'yourtaxonomyhere' ); 
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term, 'yourtaxonomyhere' );
                        if( is_wp_error( $term_link ) )
                        continue;
                    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
                    } 
?>

Rename Woocommerce menu title

add_action( 'admin_menu', 'rename_woocoomerce_wpse_100758', 999 );
function rename_woocoomerce_wpse_100758() {
    global $menu;
    $woo = recursive_array_search_php_91365( 'WooCommerce', $menu );
    if( !$woo )
        return;
        $menu[$woo][0] = 'Store Settings';
    }
function recursive_array_search_php_91365( $needle, $haystack ) {
    foreach( $haystack as $key => $value ) 
    {
        $current_key = $key;
        if( 
            $needle === $value 
            OR ( 
                is_array( $value )
                && recursive_array_search_php_91365( $needle, $value ) !== false 
            )
        ) 
        {
            return $current_key;
        }
    }
    return false;
}

remove featured image link woocommerce

add_filter('woocommerce_single_product_image_html','mbc_remove_link_on_thumbnail' ); // IF 1 image disable link
function mbc_remove_link_on_thumbnail($html){
     return strip_tags($html,'<img>');
}

Filter Query of custom post type archives via functions.php

add_filter( 'pre_get_posts', 'be_archive_query' );
function be_archive_query( $query ) {
	if( $query->is_main_query() && $query->is_post_type_archive('code') ) {
		$query->set( 'posts_per_page', 24 );
		$query->set( 'orderby', 'name' );
		$query->set( 'order', 'asc' );
	}
}

Move Yoast to bottom

function yoasttobottom() {
	return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');