Custom post type redirect in WordPress

add_action( 'template_redirect', 'aviweb_redirect_post_type' );
function aviweb_redirect_post_type() {
	$queried_post_type = get_query_var('post_type');
	if ( is_single() && 'custom_post' ==  $queried_post_type ) {
		$redirection_url = get_site_url() . '/custom_page';
		wp_redirect( $redirection_url, 301 );
	exit;
	}		
}

Get WordPress dynamic URL in JS file

//Include JS file

wp_enqueue_script('js_file', plugins_url('assets/js/js_file.js', __FILE__), array('jquery'), false);
wp_localize_script( 'js_file', 'WPURLS', array(
    'ajax_url' => admin_url( 'admin-ajax.php' )
));
	
// JS file
var url = WPURLS.ajax_url; 

Button flash using CSS3


.flash-button{
	background:#cc0000;

	color:#fff;
    border: 1px solid #cc0000;
    border-radius: 6px;
	
	animation-name: flash;
	animation-duration: 1s;
	animation-timing-function: linear;
	animation-iteration-count: infinite;


	-webkit-animation-name: flash;
	-webkit-animation-duration: 1s;
	-webkit-animation-timing-function: linear;
	-webkit-animation-iteration-count: infinite;


	-moz-animation-name: flash;
	-moz-animation-duration: 1s;
	-moz-animation-timing-function: linear;
	-moz-animation-iteration-count: infinite;
}

@keyframes flash {  
    0% { opacity: 1.0; }
    50% { opacity: 0.5; }
    100% { opacity: 1.0; }
}


@-webkit-keyframes flash {  
    0% { opacity: 1.0; }
    50% { opacity: 0.5; }
    100% { opacity: 1.0; }
}


@-moz-keyframes flash {  
    0% { opacity: 1.0; }
    50% { opacity: 0.5; }
    100% { opacity: 1.0; }
}

WordPress posts_per_page does not work

Use below code.

$web = array( 'posts_per_page' => 5,
    'orderby' => 'date',
    'order' => 'DESC',
    'no_found_rows' => true,
    'update_post_term_cache' => false,
    'update_post_meta_cache' => false,
    'nopaging' => true,
    'post_type' => 'product'
);
$query = new WP_Query( $web );

Upload file into WordPress

if ( ! function_exists( 'wp_handle_upload' ) )
require_once( ABSPATH . 'wp-admin/includes/file.php' );

$uploadedfile = $_FILES['resume'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile ) {
   echo $movefile['url'];
   echo 'Success';
}else{
   echo 'Fail';
}