WordPress.org

Ready to get started?Download WordPress

Forums

Creating a complex loop to pull different content - experts please! (1 post)

  1. orangeguru
    Member
    Posted 6 years ago #

    Aloha!

    I am currently working on a redesign for my blog (www.ultraorange.net).

    My goal is to have different sections:

    * Essay of the Week
    * normal front page blog content
    * Best of Ultraorange

    So far I have succeeded in creating a loop that contains the section "Essay of the Week" (which is the first posting of a category named featured) and the normal blog flow.

    http://www.orangeguru.biz/sandbox/

    Best of Ultraorange Section: I would like EITHER to pull the content of one page OR display all postings of the category bestof as a list (title and excerpt) in that section.

    Since I suck at that loop thingy - I'll kindly ask the local WP gurus for some help expanding the loop to show a third section ...

    Thanks a lot!

    orange

    <?php $my_query = new WP_Query('category_name=featured&showposts=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
    
    	   	<!-- start section post -->
    			<div class="post">
    
    				<!-- headline of your  post -->
    				<div class="title">
    				<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    				</div>
    				<!-- end headline of your post -->	
    
    				<!-- start entry of your  post -->
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    				<!-- end entry headline of your post -->	
    
    			</div>
    			<!-- end section post -->
    
    				<!-- start subline of your post: Author, Date, Edit and Permalink -->
    				<div class="unter">
    				<?php the_author() ?> (<?php the_time('m-d G:i') ?>) | <?php edit_post_link('Edit','','<strong>|</strong>'); ?>  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Permalink</a>
    				</div>
    				<!-- end subline of your post -->
    
    				<!--
    				<?php trackback_rdf(); ?>
    				-->
    
    </div> </div>
    
    <div id="areaBlog">
    
    <div id="contentBlog">
    
    <h1>UltraOrange Blog</h1>
    
    <!-- start section content -->
    
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
    	   	<!-- start section post -->
    			<div class="post">
    
    				<!-- headline of your  post -->
    				<div class="category"><?php the_category(', ') ?>:</div>
    				<div class="title" id="post-<?php the_ID(); ?>">
    				<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    				</div>
    			  <!-- end headline of your post -->	
    
    				<!-- start entry of your  post -->
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    				<!-- end entry headline of your post -->	
    
    					</div>
    			<!-- end section post -->
    
    				<!-- start subline of your post: Author, Date, Edit and Permalink -->
    				<div class="unter">
    				<?php the_author() ?> (<?php the_time('m-d G:i') ?>) | <?php edit_post_link('Edit','','<strong>|</strong>'); ?>  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Permalink</a>
    				</div> 			
    
    				<!-- end subline of your post -->
    
    				<!--
    				<?php trackback_rdf(); ?>
    				-->
    
    		<?php endwhile; ?>
    
    	<!-- google_ad_section_end -->			
    
    		<div class="navigation">
    			<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
    		</div>
    
    		<br />
    		<br />
    		<br />
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
    		<?php include "searchform.php"; ?>
    
    		<br />
    
    	<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic