Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Wordpress Custom Archive

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 386
    Comment on it

    alt text

    Today we will discuss about archive.php template page.
    Archive page is the great way to bring together your all old content in one page. It allow you to list your monthly archives, category archives, tag archives, author archives, and anything you want to add. You can also display your old content into sidebar but if your content is more or for large content then you will face a problem called " clutter ". To avoid clutter you can use custom archive page to display your old content, it also provides your users with an efficient way to browser through your older content.
    Below is an example of how your page-archive.php file would look like

    Using

    $post_type = 'blogs';
    $curren_years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'blogs' ORDER BY post_date DESC");
    foreach($curren_years as $current_year) {
        $current_year;
        break;              
    }
    $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'blogs' ORDER BY post_date DESC");
    echo '<ul>';
    foreach($years as $year)
    {    
        $year;                                         
        ?&gt;
        <li><a href="<?php echo get_year_link($year)." ?post_type=".$post_type; ?>"><!--?php echo $year; ?--></a></li>
        <!--?php
        $months = $wpdb--->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_type = 'blogs' AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");             
        foreach($months as $month) 
        {                   
            ?&gt;
            <ul>
            <li>            
                <a href="<?php echo get_month_link($year, $month)." ?post_type=".$post_type; ?>"><!--?php echo date( 'F', mktime(0, 0, 0, $month) );?--></a>
                <ul>
                <!--?php
                $titles = $wpdb--->get_col("SELECT post_title FROM $wpdb-&gt;posts WHERE post_type = 'blogs' AND post_status = 'publish'AND post_type = 'blogs' AND MONTH(post_date) = '".$month."' ORDER BY post_date DESC");
                $permalink = $wpdb-&gt;get_col("SELECT guid FROM $wpdb-&gt;posts WHERE post_type = 'blogs' AND post_status = 'publish'AND post_type = 'blogs' AND MONTH(post_date) = '".$month."' ORDER BY post_date DESC");          
                $i = 0;
                foreach ( $titles as $title )
                {
                    echo "<li>";
                        echo "<a href="&quot;. $permalink[$i] .&quot;">". $title ."</a>";
                    echo "</li>";
                    $i++;
                }
                ?&gt;
                </ul>
                <ul>
                    <li>
                        <a href=""><!--?php post_type_archive_title(); ?--></a>
                    </li>
                </ul>           
            </li>
            </ul>
            <!--?php           
        }   
    } 
    echo '</ul-->';
    </ul>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: