WordPress.org

Ready to get started?Download WordPress

Forums

Blix Archive - Modifing the BX_archive function (4 posts)

  1. jaredkc
    Member
    Posted 8 years ago #

    I am trying to modify the archive functions for the Blix theme. Unfortunately I do not know enough about PHP to do this. Anyone out there that can help me or point me in the right direction?

    Currently the code outputs this:
    <h3><a href="link">Month Year</a></h3>
    <ul class="postspermonth">
    <li><a href="link">Post title</a> (Comment count)</li>
    [..]
    </ul>

    I want it to output this:
    <h3><a href="link">Category</a></h3>
    <ul class="postspercategory">
    <li><a href="link">Post title</a> (Comment count)</li>
    [..]
    </ul>

    Here is the Code I am trying to edit:

    function BX_archive() {
    global $month, $wpdb;
    $now = current_time('mysql');
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_date <'" . $now . "' AND post_status='publish' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
    if ($arcresults) {
    foreach ($arcresults as $arcresult) {
    $url = get_month_link($arcresult->year, $arcresult->month);
    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
    echo get_archives_link($url, $text, '','
    <h3>','</h3>
    ');
    $thismonth = zeroise($arcresult->month,2);
    $thisyear = $arcresult->year;
    $arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status FROM " . $wpdb->posts . " WHERE post_date LIKE '$thisyear-$thismonth-%' AND post_status='publish' AND post_password='' ORDER BY post_date DESC");
    if ($arcresults2) {
    echo "
    <ul class=\"postspermonth\">
    \n";
    foreach ($arcresults2 as $arcresult2) {
    if ($arcresult2->post_date != '0000-00-00 00:00:00') {
    $url = get_permalink($arcresult2->ID);
    $arc_title = $arcresult2->post_title;
    if ($arc_title) $text = strip_tags($arc_title);
    else $text = $arcresult2->ID;
    echo "

  2. ".get_archives_link($url, $text, '');
    $comments = mysql_query("SELECT * FROM " . $wpdb->comments . " WHERE comment_post_ID=" . $arcresult2->ID);
    $comments_count = mysql_num_rows($comments);
    if ($arcresult2->comment_status == "open" OR $comments_count > 0) echo ' ('.$comments_count.')';
    echo "
  3. \n";
    }
    }
    echo "

    \n";
    }
    }
    }
    }

  4. jaredkc
    Member
    Posted 8 years ago #

    :)

  5. jaredkc
    Member
    Posted 8 years ago #

    Anyone!

  6. jkoning
    Member
    Posted 8 years ago #

    hi,

    i have a question:

    Currently the code outputs this:
    <h3>Month Year</h3>
    <ul class="postspermonth">

  7. Post title (Comment count)
  8. [..]

    i want if i click on the archive page i see all my posts, is is possible and how?

    sorry for the question, but i am very noob in wordpress :P

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags