The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Custom WordPress Archives Page

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #35218

    Sample Image

    Basically what I am hoping to accomplish is this:

    1) Nothing displays on the page at first except the row of Years
    2) User clicks on year and it loads the associated months in that row
    3) User clicks on specific month and it loads the posts below in that area

    I am having a hell of a time trying to figure out how best to accomplish this, any ideas to help point me in the right direction would be greatly appreciated.

    Template Name: Custom Archives

    Blog: Archives

    /blog" title="Latest Posts" id="back-to-posts">Latest Posts

    Select a Year

      $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");
      foreach($years as $year):
    • " title="">

      $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");
      foreach($months as $month):
    • ">

    //Query Posts by Year and Month Selected
    $monthly_posts = query_posts("cat=1&year=".$year."&monthnum=".$month."&order=DESC");

    //Count Returned Posts
    $post_count = count($monthly_posts);

    if($post_count == 1)
    echo $post_count.' blog post found';
    } else
    echo $post_count.' blog posts found';

      //If Posts Exist Display in List
      if(have_posts()): while(have_posts()) : the_post();
    • ">

    • //End Post Loop
      //End Post IF

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.