How to query for the first 5 elements published? (medicate theme)
-
here is the source code of the template. I need to query only first 5 element, may you help cause I’ve tried everything a knew
thanks<?php /*Template Name: Services */ get_header(); $prefix = 'tk_'; $enable_single = get_theme_option(tk_theme_name.'_gallery_gallery_single'); $page_headline = get_post_meta($post->ID, $prefix.'page_headline', true); $page_headline_link = get_post_meta($post->ID, $prefix.'page_headline_link', true); ?> <style> #container > div.content.left > div > div > div.service-content.left.isotope > div:nth-child(n+6) {display :none!important;} #container > div.content.left {height: 1535!important; } </style> <?php if(!empty($page_headline)) { ?> <div class="blog-single-title left"> <div class="wrapper"> <span> <?php if($page_headline_link){ ?> <a href="<?php echo $page_headline_link; ?>"> <?php } ?> <?php echo $page_headline; ?> <?php if($page_headline_link){ ?> </a> <?php } ?> </span> </div><!--/wrapper--> </div><!--blog-single-title--> <?php } ?> <?php if(empty($page_headline)) { ?> <div class="border-top-pages left"></div><!--border-top-pages--> <?php } ?> <script type="text/javascript"> jQuery(function(){ var opts = { lines: 9, // The number of lines to draw length: 6, // The length of each line width: 2, // The line thickness radius: 5, // The radius of the inner circle corners: 0.4, // Corner roundness (0..1) rotate: 0, // The rotation offset color: '#FFF', // #rgb or #rrggbb speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: true, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; var target = document.getElementById('portfolio-loader'); var spinner = new Spinner(opts).spin(target); var target2 = document.getElementById('portfolio-loader2'); var spinner2 = new Spinner(opts).spin(target2); var target3 = document.getElementById('slider-loader'); var spinner3 = new Spinner(opts).spin(target3); }); </script> <!-- CONTENT --> <div class="content left"> <div class="wrapper"> <div class="gallery-single-content left"> <div class="gallery-filter left" style="display: none;"> <span><?php _e('Filter:', tk_theme_name) ?></span> <a href="#" data-filter="*" class="active-project active"><?php _e('All', tk_theme_name) ?><p></p></a> <?php global $wpdb; $gallery_orderby = get_theme_option(tk_theme_name.'_gallery_gallery_orderby'); $gallery_order = get_theme_option(tk_theme_name.'_gallery_gallery_order'); $post_type_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'services' AND post_status = 'publish' "); if(!empty ($post_type_ids )){ $post_type_cats = wp_get_object_terms( $post_type_ids, 'ct_services',array('orderby' => $gallery_orderby, 'order' => $gallery_order, 'fields' => 'ids') ); if($post_type_cats){ $post_type_cats = array_unique($post_type_cats); } } $include_category = null; if(!empty ($post_type_ids )){ foreach ($post_type_cats as $category_list) { $cat = $category_list.","; $include_category = $include_category.$cat; $cat_name = get_term($category_list, 'ct_services'); ?> <a href="#" data-filter="<?php echo '.class-'.$category_list?>"><?php echo $cat_name->name ?><p></p></a> <?php } }?> </div><!--/gallery-filter--> <?php if($post->post_content) { ?> <div class="gallery-text left"> <div class="shortcodes"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content(); endwhile; endif; ?> </div><!--/contact-text--> </div><!--/gallery-text--> <?php } ?> <div class="portfolio-loader" id="portfolio-loader"></div> <div class="service-content left"> <?php $gallery_order = get_theme_option(tk_theme_name.'_gallery_gallery_order'); $args=array('post_type' => 'services', 'post_status' => 'publish', 'ignore_sticky_posts'=> 1, 'posts_per_page' => -1, 'order' => $gallery_order,); //The Query query_posts($args); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); $post_category = wp_get_post_terms( $post->ID, 'ct_services'); ?> <div class="service-one left <?php foreach($post_category as $post_cat){echo 'class-'.$post_cat->term_id.' ';}?>"> <?php if(has_post_thumbnail()){ ?> <div class="service-image left"><?php the_post_thumbnail('service-template'); ?></div><!--/service-image--> <?php $fullwidth = ''; } else { $fullwidth = 'fullwidth'; } ?> <div class="service-title right <?php echo $fullwidth; ?>"> <span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span> </div><!--/service-title--> <div class="service-text right <?php echo $fullwidth; ?>"> <?php if(has_post_thumbnail()){ ?> <p><?php the_excerpt_length(270); ?></p> <?php } else { ?> <p><?php the_excerpt_length(400); ?></p> <?php } ?> <span ><a href="<?php the_permalink(); ?>" class="btn btn-mini" style="float: right; background: #366507; padding: 3px 15px 3px 15px; color: #fff; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; ">Mai mult...</a> </div><!--/service-text--> </div><!--/service-one--> <?php endwhile; endif; ?> </div><!--/service-content--> </div><!--/gallery-single-content--> </div><!--/wrapper--> </div><!--/content--> <script type="text/javascript"> jQuery(function(){ var opts = { lines: 9, // The number of lines to draw length: 6, // The length of each line width: 2, // The line thickness radius: 5, // The radius of the inner circle corners: 0.4, // Corner roundness (0..1) rotate: 0, // The rotation offset color: '#FFF', // #rgb or #rrggbb speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: true, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; var target = document.getElementById('portfolio-loader'); var spinner = new Spinner(opts).spin(target); var target2 = document.getElementById('portfolio-loader2'); var spinner2 = new Spinner(opts).spin(target2); }) jQuery(document).ready(function(){ //LOAD ISOTOPE var container = jQuery('.service-content'); jQuery(container).imagesLoaded(function(){ jQuery('.portfolio-loader').attr('style', 'display:none'); jQuery(container).show().animate({opacity:1},1000); jQuery('.service-content').show(); jQuery(container).isotope({ ? ? ? ? ? ?layoutMode : 'fitRows' , itemSelector: '.service-one', isAnimated: true, animationEngine : 'jquery', animationOptions: { duration: 800, easing: 'easeOutCubic', queue: false } }); }); jQuery('.service-content').imagesLoaded(function(){ jQuery('.portfolio-loader2').attr('style', 'display:none'); jQuery('.gallery-single-images').attr('style', 'display:inline-block'); }); jQuery('.gallery-filter a').each(function(){ jQuery(this).click(function(){ jQuery('.gallery-filter a').each(function(){ jQuery(this).removeClass('active'); }); jQuery(this).addClass('active'); }); }); jQuery('.gallery-filter a').click(function(){ var selector = jQuery(this).attr('data-filter'); jQuery(container).isotope({ filter: selector }); return false; }); jQuery(function($) { jQuery("<select />").appendTo(".gallery-filter"); // Create default option "Go to..." jQuery("<option />", { "selected": "selected", "value" : "", "text" : "Mergi la..." }).appendTo(".gallery-filter select"); // Populate dropdown with menu items jQuery(".gallery-filter a").each(function() { var el = $(this); jQuery("<option />", { "value" : el.attr("href"), "data-filter" : el.attr("data-filter"), "text" : el.text() }).appendTo(".gallery-filter select"); }); // To make dropdown actually work // To make more unobtrusive: https://css-tricks.com/4064-unobtrusive-page-changer/ jQuery(".gallery-filter select").change(function() { var container = jQuery('.service-content'); var selector = jQuery(this).find("option:selected").attr('data-filter'); jQuery(container).isotope({ filter: selector }); return false; }); }); }); </script> <?php get_footer(); ?>
- The topic ‘How to query for the first 5 elements published? (medicate theme)’ is closed to new replies.