'post',
'posts_per_page' => '-1',
'category_name' => ! empty( $themotion_video_category ) && 'all' != $themotion_video_category ? esc_html( $themotion_video_category ) : '',
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
have_posts() ) {
$the_query->the_post();
if ( 3 == $post_count ) {
break;
}
$id = get_the_ID();
if ( has_post_format( 'video', $id ) ) {
$post = get_post( $id );
$content = apply_filters( 'the_content', $post->post_content );
$embeds = get_media_embedded_in_content( $content );
if ( ! empty( $embeds ) ) { ?>
'post',
'posts_per_page' => '-1',
'category_name' => ! empty( $themotion_video_category ) && 'all' != $themotion_video_category ? esc_html( $themotion_video_category ) : '',
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$id = get_the_ID(); ?>
post_content );
$embeds = get_media_embedded_in_content( $content );
if ( ! empty( $embeds ) ) {
echo themotion_escape_lightbox( $embeds[0] );
}
} else {
if ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$thumb_meta = wp_get_attachment_metadata( $thumb_id );
if ( ! empty( $thumb_id ) && 0 != $thumb_meta['width'] && 0 != $thumb_meta['height'] ) {
if ( $thumb_meta['width'] / $thumb_meta['height'] > 1 ) {
the_post_thumbnail( 'themotion-thumbnail-blog' );
} else {
the_post_thumbnail( 'themotion-thumbnail-blog-no-crop' );
}
}
}
} ?>
have_posts() ) {
$first = 'true';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$id = get_the_ID();
$attached_video = get_attached_media( 'video', $id );
if ( ! empty( $attached_video ) ) {
foreach ( $attached_video as $video ) {
$video_id = $video->ID;
$video_meta = wp_get_attachment_metadata( $video_id );
$video_length = $video_meta['length_formatted'];
break;
}
}?>
'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'ignore_sticky_posts' => 1,
);
if ( ! empty( $themotion_cat ) ) {
$args['category_name'] = $themotion_cat;
}
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
have_posts() ) {
$the_query->the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'about' );
}
the_posts_navigation( array(
'prev_text' => sprintf( '← %s', __( 'Older Posts', 'themotion' ) ),
'next_text' => sprintf( '%s →', __( 'Newer Posts', 'themotion' ) ),
)
);
} else {
get_template_part( 'template-parts/content', 'none' );
}
/* Restore original Post Data */
wp_reset_postdata();
}
/**
* Live Update Bottom of Home A.
*/
function themotion_ajax_homea_bottom( $themotion_video_category ) {
$themotion_cat = ( ! empty( $themotion_video_category ) && 'all' != $themotion_video_category ? $themotion_video_category : '');
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 6,
'ignore_sticky_posts' => 1,
);
if ( ! empty( $themotion_cat ) ) {
$args['category_name'] = $themotion_cat;
}
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
have_posts() ) {
$the_query->the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'home-one' );
}
the_posts_navigation( array(
'prev_text' => sprintf( '← %s', __( 'Older Posts', 'themotion' ) ),
'next_text' => sprintf( '%s →', __( 'Newer Posts', 'themotion' ) ),
)
);
} else {
get_template_part( 'template-parts/content', 'none' );
}
/* Restore original Post Data */
wp_reset_postdata();
}
/**
* Live Update Bottom of Home B.
*/
function themotion_ajax_homeb_bottom( $themotion_video_category ) {
$themotion_cat = ( ! empty( $themotion_video_category ) && 'all' != $themotion_video_category ? $themotion_video_category : '');
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'ignore_sticky_posts' => 1,
);
if ( ! empty( $themotion_cat ) ) {
$args['category_name'] = $themotion_cat;
}
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
have_posts() ) {
$the_query->the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'home-two' );
}
the_posts_navigation( array(
'prev_text' => sprintf( '← %s', __( 'Older Posts', 'themotion' ) ),
'next_text' => sprintf( '%s →', __( 'Newer Posts', 'themotion' ) ),
)
);
} else {
get_template_part( 'template-parts/content', 'none' );
}
/* Restore original Post Data */
wp_reset_postdata();
}
add_action( 'wp_ajax_nopriv_request_post', 'themotion_requestpost' );
add_action( 'wp_ajax_request_post', 'themotion_requestpost' );
/**
* Post Request.
*/
function themotion_requestpost() {
$themotion_page = $_POST['page'];
if ( 'homeb' == $themotion_page ) {
$themotion_video_category = $_POST['category'];
$themotion_is_hidden = $_POST['is_hidden'];
themotion_ajax_homeb( $themotion_video_category, $themotion_is_hidden );
} elseif ( 'homea' == $themotion_page ) {
$themotion_video_category = $_POST['category'];
themotion_ajax_homea( $themotion_video_category );
} elseif ( 'about' == $themotion_page ) {
$themotion_video_category = $_POST['category'];
themotion_ajax_about( $themotion_video_category );
} elseif ( 'homea_bottom' == $themotion_page ) {
$themotion_video_category = $_POST['category'];
themotion_ajax_homea_bottom( $themotion_video_category );
} elseif ( 'homeb_bottom' == $themotion_page ) {
$themotion_video_category = $_POST['category'];
themotion_ajax_homeb_bottom( $themotion_video_category );
}
die();
}