Skip to content

Instantly share code, notes, and snippets.

@manoj-singh-developer
Last active March 13, 2019 12:34
Show Gist options
  • Select an option

  • Save manoj-singh-developer/d19726fc377fc6e5048ab29a75e3983f to your computer and use it in GitHub Desktop.

Select an option

Save manoj-singh-developer/d19726fc377fc6e5048ab29a75e3983f to your computer and use it in GitHub Desktop.
<?php /* Template Name: Hotel Custom */ ?>
<?php
$args = array(
'post_type' => 'hotel_listing', //remember this is-case sensitive
'posts_per_page' => -1,
);
$releaseQuery = new WP_Query( $args );
if ( $releaseQuery->have_posts() ) :
while ( $releaseQuery->have_posts() ) :
$mn = $releaseQuery->the_post();
//print_r()
$c_id = get_the_ID();
//echo get_the_title();
//echo the_content();
$am = get_post_meta($c_id, 'price', true);
//print_r($am);
endwhile;
endif;
wp_reset_query();
$my_query = new WP_Query('post_type=hotel_listing');
foreach($my_query->posts as $post) {
//print_r($post);
?>
<?php //echo $post->post_title; ?>
<?php
//echo $am = get_post_meta($post->ID, 'price', true);
//echo $am = get_post_meta($post->ID, 'details', true);
$postId = $post->ID;
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ));
$im = $dynamic_featured_image->get_featured_images([$postId]);
//print_r($image);
print_r($im);
}
?>
==================================================
<?php
$args = array(
'post_type' => 'hotel_listing',
'posts_per_page' => 4
);
$query = new WP_Query($args);
while ($query->have_posts()):
$query->the_post();
print_r($query);
?>
<h2> <?php the_title(); ?> </h2>
<p>Meta: <?php //echo the_meta()->detail; ?> </p>
<p>Excerpt: <?php echo the_excerpt();?> </p>
<?php
$terms = wp_get_post_terms($query->post->ID, array(
'hotel_type',
));
?> <?php
foreach ($terms as $term):
?> <p><?php
echo $term->taxonomy;
?>: <?php
echo $term->name;
?></p> <?php
endforeach;
?> <?php
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment