Monday 9 February 2015

jquery parallax background image

$(document).ready(function(jQuery) {

    $('.my_testimonial').each(function($) {

// assigning the object
var bgobj = jQuery(".my_testimonial");

        jQuery(window).scroll(function($){

            var sco_top = jQuery(window).scrollTop();
            var yPos = -(sco_top / 1.7);

            // Put together our final background position
            var coords = '50% ' + yPos + 'px';
            console.log(coords);

            // Move the background
            jQuery(".my_testimonial").css("backgroundPosition", coords);

        });
    });

});

Get post between dates in wordpress




$args = array(
'posts_per_page'   => -1,
'order'            => 'DESC',
'post_type'        => 'post',
'post_status'      => 'publish',
'cat'          => 59,
'date_query'  => array(
array(
'after'     => array(
'year'    => 2015,
'month'   => 02,
'day' => 06,
'hour' => 10,
'minute'  => 28,
'second'  => 55,
),
'before'    => array(
'year'    => 2015,
'month'   => 02,
'day' => 09,
'hour' => 15,
'minute'  => 24,
'second'  => 01,
),
),
),
);

$query_result = new WP_Query($args);


User can access only own media in wordpress




add_filter( 'ajax_query_attachments_args', 'show_users_own_attachments', 1, 1 );

function show_users_own_attachments($query){
  $id = get_current_user_id();
  if( !current_user_can('manage_options') )
  $query['author'] = $id;
  return $query;
}