• Resolved toimisto

    (@toimisto)


    Thanks for the BRILLIANT plugin. I’m struggling with query at the moment and wondered if someone here knows answer. I have a following query but I’d need to get UL tags inside if statement (and some other stuff). Any idea? Normal ‘if while’ structure leads to errors

    <ul>
    <?php
    global $post;
    $args = array( 'numberposts' => 500, 'orderby' => 'date', 'year' => '2012', 'order' => 'ASC', 'document_language' => 'english');
    $myposts = get_documents( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

    http://wordpress.org/extend/plugins/wp-document-revisions/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ben Balter

    (@benbalter)

    Can you write out (in psuedo-code if need be) what you’re trying to do?

    Because documents are just posts, you should be able to query it normally, such as using wp_query or get_posts, if need be.

    Thread Starter toimisto

    (@toimisto)

    <?php
    global $post;
    $args = array( 'numberposts' => 500, 'orderby' => 'date', 'year' => '2012', 'order' => 'ASC', 'document_language' => 'english');
    $myposts = get_documents( $args );
    <strong>
    if ( $myposts->have_posts() ) : $myposts->the_post(); { ?>
    <h1>Year 2012</h1>
    <? } while ( $myposts->have_posts() ) : $myposts->the_post(); ?>
    <strong>
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    <?php endwhile; endif; ?>

    I need to create a page with yearly archives and I thought it would be quickest just to query every year there manually. Problem is that I’d need few future years there also but I dont want these titles show up before there is documents for that year

    Thread Starter toimisto

    (@toimisto)

    nevermind that < strong > there just tried to highlight that part… without thinking too much obviously

    Plugin Author Ben Balter

    (@benbalter)

    Ahh, I see. If you change get_documents to WP_Query, and add 'post_type' => 'document' to the $args array, the above code should work as expected, I believe. get_documents behaves like get_posts, not WP_Query (returning an array versus a query object which you can iterate through like you are above).

    Thread Starter toimisto

    (@toimisto)

    brilliant so simple! THANK YOU!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP Document Revisions] Wp doc rev: How to query properly’ is closed to new replies.