WordPress.org

Ready to get started?Download WordPress

Forums

query_posts causing page load delay - Best alternative? (2 posts)

  1. Pendulum
    Member
    Posted 1 year ago #

    I'm currently using query_posts to select posts with a specific tag to display. I have to do this a total of 6 times on one page, with a different tag being pulled each time.

    I know there's got to be a better way to do this... I'm getting some page load delays from the code below. Any help is greatly appreciated!

    <?php query_posts('tag=home_1&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
    
    						<?php query_posts('tag=home_2&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
    
    						<?php query_posts('tag=home_3&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
    
    						<?php query_posts('tag=home_4&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
    
    						<?php query_posts('tag=home_5&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
    
    						<?php query_posts('tag=home_6&category=1&posts_per_page=1'); ?>
    
    						<?php while (have_posts()) : the_post(); ?>
    
    							<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    								<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'home-thumbnails' ); ?>
    						    	<header class="article-header">
    
    							    	<h1><?php the_title(); ?><img src="/wp-content/themes/az***/library/images/arrows.png" class="arrow" alt="Post Arrows" title="post arrows" /></a></h1>
    
    						    	</header><!-- end article header -->
    
    					   		 </article><!-- end article -->
    
    						<?php endwhile; ?>
    
    						<?php rewind_posts; ?>
  2. touchrandr
    Member
    Posted 1 year ago #

    Hi,

    I use the below code to get different post type, but my page loads,
    it sucks my whole system process.

    $args = array(
    'orderby' => 'post_date',
    'order' => 'DESC',
    'post_type' => 'post-faq',
    'post_status' => 'publish'
    );

    return $faq_array = query_posts( $args );

    We can try the WP_Query()
    WP_Query

Topic Closed

This topic has been closed to new replies.

About this Topic