Skip to content

Instantly share code, notes, and snippets.

@cethap
Last active August 29, 2015 14:04
Show Gist options
  • Save cethap/f1c4ededfe5b422a2728 to your computer and use it in GitHub Desktop.
Save cethap/f1c4ededfe5b422a2728 to your computer and use it in GitHub Desktop.
wordpress
<?php
/**
* SlideCamerajs
*/
function SlideCamerajs($attr) {
$attr = shortcode_atts(
array(
'height' => '320',
'titulo' => '',
),
$attr
);
?>
<div class="camera_wrap camera_emboss" id="camera_wrap_4" style="height: <?php echo $attr["height"] ?>px;">
<?php
//$page = get_page_by_title('Vidriera del valle');
$idMain = 0;
if(trim($attr["titulo"]) !=""){
$idMain = get_page_by_title($attr["titulo"])->ID;
if(!$idMain){
$idMain = get_the_ID();
}
}else{
$idMain = get_the_ID();
}
$query_images_args = array('post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'post_parent' => $idMain,'orderby'=>'rand');
$query_images = new WP_Query( $query_images_args );
$images = "";
//var_dump($query_images->posts);
foreach ( $query_images->posts as $image) {
$alt = get_post_meta($image->ID, '_wp_attachment_image_alt', true);
if($image->post_excerpt == "banner"){
?>
<div data-src="<?php echo $image->guid; ?>"></div>
<?php
}
}
?>
</div>
<?php
}
add_shortcode( 'SlideCamerajs', 'SlideCamerajs' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment