How to display the Post in page Template instead of single post
-
Hello
I have a website where I have used the Carousel to display the specific category post into Carousel slider and post are around 1000+.
When some one click on the slider post it open the post into new page (single post), I want to display the post into same page below the slider.
Please let me know how to achieve this.
And there is another problem occur I have selected the 3 specific category to display the post into slider, but its showing all post. I don’t want to show all post. I want to show only 3 category post. you can see the my code here
============================
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
<?php /** * Template Name: News * * @package WordPress */ get_header(); ?> <div class="container"> <div class=""> <div class="row"> <div class="col-md-12"> <div class="carousel slide multi-item-carousel" id="theCarousel"> <div class="carousel-inner"> <?php /*?> <?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id(153) ); ?><?php */?> <?php $type = 'post'; $args = array( 'posts_per_page' => 1000, 'category' => 9,13,14, 'post_type' => $type, 'post_status' => 'publish', ); $posts_array = get_posts( $args ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $counter = 0; while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php if( class_exists('Dynamic_Featured_Image') ) { global $dynamic_featured_image; $featured_images = $dynamic_featured_image->get_featured_images($post->ID); foreach($featured_images as $key=>$postimages ) { if($counter==0) { ?> <div class="item active"> <div class="col-xs-4 nopadding"><a>" target="_top"><img src="<?php echo $postimages['full'] ?>" class="img-responsive"></a></div> </div> <?php } else { ?> <div class="item"> <div class="col-xs-4 nopadding"><a>" target="_top"><img src="<?php echo $postimages['full'] ?>" class="img-responsive"></a></div> </div> <?php } $counter++; } } ?> <?php endwhile; } wp_reset_query(); ?> </div> <a href="#theCarousel"><i class="glyphicon glyphicon-chevron-left"></i></a> <a href="#theCarousel"><i class="glyphicon glyphicon-chevron-right"></i></a> </div> </div> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12 nopadding"> <div class="col-md-12 col-sm-12 col-xs-12 nopadding"> <div class="midcontent"><?php the_field('middlecontent');?> </div> </div> </div> <div class="wc_border_bottom col-md-12 col-sm-12 col-xs-12 nopadding"> <div class="col-md-1 col-sm-1 col-xs-12 nopadding"> <div class="imgicon"> <img src="<?php the_field('leftimgicon'); ?>" /> </div> </div> <div class="col-md-11 col-sm-11 col-xs-12 nopadding"> <div class="wcbox"> <div class="sliderbot"> <h3 style="color: #ff6600;"><?php echo $bottomtitle ?></h3> <p><?php echo $bottomcontent ?></p> </div> </div> </div> </div> <div class="wccontent cleafix"> <?php //$type = 'news__insights'; $args=array( 'post_type' => post, 'post_status' => 'publish', 'posts_per_page' => 1, //'caller_get_posts'=> 1 'cat' => 9,13,14,// ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <div class="nopadding col-md-12 no-padding-left feat_img post-imge"> <?php /*?> <div class="entry-date"><span class="w-date"><?php echo get_the_date(); ?></span></div><?php */?> <?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <img src="<?php echo $feat_image ?>"> </div> <?php echo '<div class="entry-content bolgcant">'; $string = $post->post_content; $newString = substr($string, 0, 100000); echo $newString; echo '</div>'; ?> </div> <?php endwhile; }?> </div> </div> <?php get_footer(); ?> <script> // Instantiate the Bootstrap carousel jQuery('.multi-item-carousel').carousel({ interval: false }); // for every slide in carousel, copy the next slide's item in the slide. // Do the same for the next, next item. jQuery('.multi-item-carousel .item').each(function(){ var next = jQuery(this).next(); if (!next.length) { next = jQuery(this).siblings(':first'); } next.children(':first-child').clone().appendTo(jQuery(this)); if (next.next().length>0) { next.next().children(':first-child').clone().appendTo(jQuery(this)); } else { jQuery(this).siblings(':first').children(':first-child').clone().appendTo(jQuery(this)); } }); </script>
- The topic ‘How to display the Post in page Template instead of single post’ is closed to new replies.