Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

loop.php exclude category
Friday, November 16th, 2012 at 7:25:15pm UTC 

  1. <?php
  2. /**
  3. * The loop that displays posts.
  4. *
  5. * The loop displays the posts and the post content. See
  6. * http://codex.wordpress.org/The_Loop to understand it and
  7. * http://codex.wordpress.org/Template_Tags to understand
  8. * the tags used in it.
  9. *
  10. * This can be overridden in child themes with loop.php or
  11. * loop-template.php, where 'template' is the loop context
  12. * requested by a template. For example, loop-index.php would
  13. * be used if it exists and we ask for the loop with:
  14. * <code>get_template_part( 'loop', 'index' );</code>
  15. *
  16. * @package WordPress
  17. * @subpackage Twenty_Ten
  18. * @since Twenty Ten 1.0
  19. */
  20. ?>
  21.  
  22. <?php
  23.         if ( is_home()) {
  24.         query_posts($query_string . '&cat=-9&posts_per_page=3' );
  25.         }
  26. ?>
  27.  
  28. <?php /* Display navigation to next/previous pages when applicable */ ?>
  29. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  30.         <div id="nav-above" class="navigation">
  31.                 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  32.                 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  33.         </div><!-- #nav-above -->
  34. <?php endif; ?>
  35.  
  36. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  37. <?php if ( ! have_posts() ) : ?>
  38.         <div id="post-0" class="post error404 not-found">
  39.                 <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  40.                 <div class="entry-content">
  41.                         <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  42.                         <?php get_search_form(); ?>
  43.                 </div><!-- .entry-content -->
  44.         </div><!-- #post-0 -->
  45. <?php endif; ?>
  46. <?php wp_reset_query(); ?>
  47. <?php
  48.         /* Start the Loop.
  49.          *
  50.          * In Twenty Ten we use the same loop in multiple contexts.
  51.          * It is broken into three main parts: when we're displaying
  52.          * posts that are in the gallery category, when we're displaying
  53.          * posts in the asides category, and finally all other posts.
  54.          *
  55.          * Additionally, we sometimes check for whether we are on an
  56.          * archive page, a search page, etc., allowing for small differences
  57.          * in the loop on each template without actually duplicating
  58.          * the rest of the loop that is shared.
  59.          *
  60.          * Without further ado, the loop:
  61.          */ ?>
  62. <?php while ( have_posts() ) : the_post(); ?>
  63.  
  64. <?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?>
  65.  
  66.         <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
  67.                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  68.                         <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  69.  
  70.                         <div class="entry-meta">
  71.                                 <?php twentyten_posted_on(); ?>
  72.                         </div><!-- .entry-meta -->
  73.  
  74.                         <div class="entry-content">
  75. <?php if ( post_password_required() ) : ?>
  76.                                 <?php the_content(); ?>
  77. <?php else : ?>
  78.                                 <?php
  79.                                         $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  80.                                         if ( $images ) :
  81.                                                 $total_images = count( $images );
  82.                                                 $image = array_shift( $images );
  83.                                                 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  84.                                 ?>
  85.                                                 <div class="gallery-thumb">
  86.                                                         <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  87.                                                 </div><!-- .gallery-thumb -->
  88.                                                 <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ),
  89.                                                                 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  90.                                                                 number_format_i18n( $total_images )
  91.                                                         ); ?></em></p>
  92.                                 <?php endif; ?>
  93.                                                 <?php the_excerpt(); ?>
  94. <?php endif; ?>
  95.                         </div><!-- .entry-content -->
  96.  
  97.                         <div class="entry-utility">
  98.                         <?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?>
  99.                                 <a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
  100.                                 <span class="meta-sep">|</span>
  101.                         <?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
  102.                                 <a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
  103.                                 <span class="meta-sep">|</span>
  104.                         <?php endif; ?>
  105.                                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  106.                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  107.                         </div><!-- .entry-utility -->
  108.                 </div><!-- #post-## -->
  109.  
  110. <?php /* How to display posts of the Aside format. The asides category is the old way. */ ?>
  111.  
  112.         <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) )  ) : ?>
  113.                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  114.  
  115.                 <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  116.                         <div class="entry-summary">
  117.                                 <?php the_excerpt(); ?>
  118.                         </div><!-- .entry-summary -->
  119.                 <?php else : ?>
  120.                         <div class="entry-content">
  121.                                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  122.                         </div><!-- .entry-content -->
  123.                 <?php endif; ?>
  124.  
  125.                         <div class="entry-utility">
  126.                                 <?php twentyten_posted_on(); ?>
  127.                                 <span class="meta-sep">|</span>
  128.                                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  129.                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  130.                         </div><!-- .entry-utility -->
  131.                 </div><!-- #post-## -->
  132.  
  133. <?php /* How to display all other posts. */ ?>
  134.  
  135.         <?php else : ?>
  136.                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  137.                         <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  138.  
  139.                         <div class="entry-meta">
  140.                                 <!-- the call below the_time(x, x, x); adds the date of the post -->
  141.                                 Posted on <span class="date"><?php the_time('M j, Y'); ?></span>
  142.                                 <!-- and then of coarse the by the_author_posts_link(); -->
  143.                                 by <?php the_author_posts_link(); ?>.
  144.                                 <?php if ( count( get_the_category() ) ) : ?>
  145.                                         <span class="cat-links">
  146.                                                 <?php printf( __( '<span class="%1$s">Filed under</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  147.                                         </span>
  148.                                         <span class="meta-sep">|</span>
  149.                                 <?php endif; ?>
  150.                                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>                            
  151.                                 <!-- the entry meta below was commented out so that we could change it to something else -->
  152.                                 <!-- <?php twentyten_posted_on(); ?> -->
  153.                                 <!-- Display Twitter handle -->
  154.                                 Twitter Handle: <?php the_author_meta('twitter'); ?>
  155.                         </div><!-- .entry-meta -->
  156.  
  157.         <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
  158.                         <div class="entry-summary">
  159.                                 <?php if (has_post_thumbnail()) { ?>       
  160.                                         <div class="featuredImage">
  161.                                                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  162.                                                         <?php the_post_thumbnail('small')?>
  163.                                                 </a>
  164.                                         </div>
  165.                                 <?php } ?>
  166.                                 <?php the_excerpt(); ?>
  167.                         </div><!-- .entry-summary -->
  168.         <?php else : ?>
  169.                         <div class="entry-content">
  170.                                 <?php if (has_post_thumbnail()) { ?>
  171.                                         <div class="featuredImage">
  172.                                                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  173.                                                         <?php the_post_thumbnail('medium')?>
  174.                                                 </a>
  175.                                         </div>
  176.                                 <?php } ?>
  177.                                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  178.                                 <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  179.                         </div><!-- .entry-content -->
  180.         <?php endif; ?>
  181.  
  182.                         <div class="entry-utility">
  183.                                 <?php if ( count( get_the_category() ) ) : ?>
  184.                                         <span class="cat-links">
  185.                                                 <?php printf( __( '<span class="%1$s">Filed under</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  186.                                         </span>
  187.                                         <span class="meta-sep">|</span>
  188.                                 <?php endif; ?>
  189.                                 <?php
  190.                                         $tags_list = get_the_tag_list( '', ', ' );
  191.                                         if ( $tags_list ):
  192.                                 ?>
  193.                                         <span class="tag-links">
  194.                                                 <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
  195.                                         </span>
  196.                                         <span class="meta-sep">|</span>
  197.                                 <?php endif; ?>
  198.                                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  199.                                 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  200.                         </div><!-- .entry-utility -->
  201.                 </div><!-- #post-## -->
  202.  
  203.                 <?php comments_template( '', true ); ?>
  204.  
  205.         <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  206.  
  207. <?php endwhile; // End the loop. Whew. ?>
  208.  
  209. <?php /* Display navigation to next/previous pages when applicable */ ?>
  210. <?php if (  $wp_query->max_num_pages > 1 ) : ?>
  211.                                 <div id="nav-below" class="navigation">
  212.                                         <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  213.                                         <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  214.                                 </div><!-- #nav-below -->
  215. <?php endif; ?>

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right