Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter roelof

    (@roelof)

    Can this pseudo code work.

    <?php
    /** Load the Core Files */
    require_once( trailingslashit( get_template_directory() ) . 'lib/init.php' );
    new Contango();
    
    add_filter( 'getarchives_where', 'customarchives_where' );
    add_filter( 'getarchives_join', 'customarchives_join' );
    
    function customarchives_join( $x ) {
    
        global $wpdb;
    
        articles =  " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
      for each article
            month = <?php the_time('M')
            year = <<?php the_time('Y')
            prev_year = 0
            <ul>
               $year
            while prev_year is not equal to year
                  <li>
                      <a href="<?php echo get_month_link( $year,$month ); ?>"> <?php the_time('F Y'); ?>
    </a>
               prev_year = $year
                   </li>
            endwhile
             </ul>
        endforeach
    
    }

    Roelof

    Moderator bcworkz

    (@bcworkz)

    Depends on what you really want to get out of it. The filters enable you to change what’s queried and how it’s restricted by category or tags or something similar, but there is nothing to alter the output format. If you want post counts, you cannot get them by using wp_get_archive(), which is why the article’s author simply did his own thing entirely.

    If you want post counts, you’re better off using the article’s code as a starting point and develop your own error free code.

    Thread Starter roelof

    (@roelof)

    Chips.

    I need to alter the layout to get what I want.
    A archive which looks like the site on my first post.
    I have no problem that the counting is not present. That part I do need. What I need is the part that the year is seperated from the months.I tried to use the code on that page but it seems to have many errors. And Im have little to none knowlegde of C to make it work.

    Maybe there is another way to achieve what I want.

    Roelof

    Thread Starter roelof

    (@roelof)

    Thread Starter roelof

    (@roelof)

    Chips the same message as the other script :Parse error: syntax error, unexpected ‘<‘ in /home/vhosting/c/vhost0008707/domains/tamarawobben.nl/htdocs/test/wp-content/plugins/custom_archive/archive_custom.php on line 60

    Roelof

    Moderator bcworkz

    (@bcworkz)

    I tested both scripts on my installation and they both ran without error and generated the expected output. The problem is probably where you inserted the code and/or how you’re using it.

    You need to be careful where you insert code, you cannot nest <?php ?> blocks. If you insert code into another <?php ?> block, you need to remove the extra <?php and ?> tags. When inserting <?php ?> blocks into HTML portions, you need to ensure the output does not disrupt adjacent HTML and that the final output is valid HTML. Or there just may be an extra or missing character, such as angle bracket, quote, parenthesis, semi-colon, or other similar delimiters.

    This sort of code is usually inserted in the theme’s sidebar.php file, though it can go in any template file. It can also be used as a part of a plugin, but then some extra coding is required in order to inject the output where you want it to appear.

    Thread Starter roelof

    (@roelof)

    I want to use it into a widget and then a lot of errors appear.
    Also a moderator of wordpress.stackexchange said it is a broken script with also some secrity problems. So I think I follow a course in PHP and do it myself.

    Roelof

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can this be done with wp_archive_get’ is closed to new replies.