Advertisement
shakil97bd

Code For Archive.php file in wordpress theme

Feb 3rd, 2015
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. ******************** Code For Archive.php file in wordpress theme ****************
  2.  
  3. //Just past this code in archive.php file, where you want to show archive post
  4.  
  5.  
  6.  
  7. <h1>
  8.  
  9.     <?php if (have_posts()) : ?>
  10.  
  11.         <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  12.  
  13.             <?php /* If this is a category archive */ if (is_category()) { ?>
  14.  
  15.                 <?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?>                                    
  16.  
  17.             <?php /* If this is a tag archive */  } elseif( is_tag() ) { ?>
  18.  
  19.                 <?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag
  20.  
  21.             <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
  22.  
  23.                 <?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?>                                        
  24.  
  25.             <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
  26.  
  27.                 <?php _e('Archive for'); ?> <?php the_time('F, Y'); ?>                                    
  28.  
  29.             <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
  30.  
  31.                 <?php _e('Archive for'); ?> <?php the_time('Y'); ?>                                        
  32.  
  33.             <?php /* If this is a search */ } elseif (is_search()) { ?>
  34.  
  35.                 <?php _e('Search Results'); ?>                            
  36.  
  37.             <?php /* If this is an author archive */ } elseif (is_author()) { ?>
  38.  
  39.                 <?php _e('Author Archive'); ?>                                        
  40.  
  41.             <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
  42.  
  43.                 <?php _e('Blog Archives'); ?>                                        
  44.  
  45.     <?php } ?>
  46.  
  47. </h1>               //(<h1></h1>) all code is for Archive post title
  48.  
  49. <?php get_template_part('post_loop'); ?>        //This is the loop of the post
  50.            
  51.            
  52.            
  53.     ***************************************************************************************    
  54.            
  55. NOTE :You can call post loop here directly or separately.But you must call the post-loop here to show the post of the archive.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement